https://t.me/RX1948
Server : Apache
System : Linux iad1-shared-b8-43 6.6.49-grsec-jammy+ #10 SMP Thu Sep 12 23:23:08 UTC 2024 x86_64
User : dh_edsupp ( 6597262)
PHP Version : 8.2.26
Disable Function : NONE
Directory :  /lib/python3/dist-packages/django/contrib/gis/gdal/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //lib/python3/dist-packages/django/contrib/gis/gdal/__pycache__/layer.cpython-310.pyc
o

�aP!�@s�ddlmZmZddlmZddlmZmZddlm	Z	m
Z
ddlmZddl
mZddlmZddlmZdd	lmZmZmZdd
lmZddlmZmZGdd
�d
e�ZdS)�)�byref�c_double)�GDALBase)�Envelope�OGREnvelope)�
GDALException�SRSException)�Feature)�
OGRFieldTypes)�OGRGeometry)�OGRGeomType)�ds�geom�srs)�SpatialReference)�force_bytes�	force_strc@s�eZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	e
dd��Ze
dd��Ze
d/dd��Z
e
dd��Ze
dd��Ze
dd��Ze
dd��Ze
dd��Ze
dd ��Ze
d!d"��Zd#d$�Zd%d&�Ze
ee�Zd'd(�Zd0d*d+�Zd,d-�Zd.S)1�LayerzSA class that wraps an OGR Layer, needs to be instantiated from a DataSource object.cCs6|std��||_||_t�|j�|_|�d�|_dS)a7
        Initialize on an OGR C pointer to the Layer and the `DataSource` object
        that owns this layer.  The `DataSource` object is required so that a
        reference to it is kept with this Layer.  This prevents garbage
        collection of the `DataSource` while this Layer is still active.
        z*Cannot create Layer, invalid pointer givens
RandomReadN)	r�ptr�_ds�capi�get_layer_defn�_ptr�_ldefn�test_capability�_random_read)�self�	layer_ptrr
�r�?/usr/lib/python3/dist-packages/django/contrib/gis/gdal/layer.py�__init__szLayer.__init__csbt|t�r|dkr
td����|�St|t�r-|��j�\}}}�fdd�t|||�D�Std��)z'Get the Feature at the specified index.rz/Negative indices are not allowed on OGR Layers.csg|]}��|��qSr)�
_make_feature)�.0�fid�rrr�
<listcomp>3�z%Layer.__getitem__.<locals>.<listcomp>z>Integers and slices may only be used when indexing OGR Layers.)	�
isinstance�int�
IndexErrorr!�slice�indices�num_feat�range�	TypeError)r�index�start�stop�striderr$r�__getitem__'s


zLayer.__getitem__ccs6�t�|j�t|j�D]}tt�|j�|�VqdS)z'Iterate over each Feature in the Layer.N)r�
reset_readingrr-r,r	�get_next_feature)r�irrr�__iter__7s
��zLayer.__iter__cC�|jS)z%The length is the number of features.)r,r$rrr�__len__>�z
Layer.__len__cCr8)zThe string name of the layer.)�namer$rrr�__str__Br:z
Layer.__str__cCsX|jrztt�|j|�|�WStyYnw|D]}|j|kr%|Sqtd|��)a.
        Helper routine for __getitem__ that constructs a Feature from the given
        Feature ID.  If the OGR Layer does not support random-access reading,
        then each feature of the layer will be incremented through until the
        a Feature is found matching the given feature ID.
        zInvalid feature id: %s.)rr	r�get_featurerrr#r))r�feat_id�featrrrr!Fs�
�zLayer._make_featurecCs"t�}t�|jt|�d�t|�S)z.Return the extent (an Envelope) of this layer.�)rr�
get_extentrrr)r�envrrr�extent]szLayer.extentcCst�|j�}t||jjdd�S)z1Return the name of this layer in the Data Source.T��strings_only)r�get_fd_namerrr�encoding)rr;rrrr;dsz
Layer.namer@cCst�|j|�S)z+Return the number of features in the Layer.)r�get_feature_countr)r�forcerrrr,jszLayer.num_featcCst�|j�S)z)Return the number of fields in the Layer.)r�get_field_countrr$rrr�
num_fieldsoszLayer.num_fieldscCstt�|j��S)z4Return the geometry type (OGRGeomType) of the Layer.)rr�get_fd_geom_typerr$rrr�	geom_typetszLayer.geom_typecCs2zt�|j�}tt�|��WStyYdSw)z0Return the Spatial Reference used in this Layer.N)r�
get_layer_srsrr�srs_api�	clone_srsr)rrrrrrys�z	Layer.srsc��fdd�t�j�D�S)zt
        Return a list of string names corresponding to each of the Fields
        available in this Layer.
        c	s.g|]}tt�t��j|���jjdd��qS)TrD)rr�get_field_name�get_field_defnrrrG�r"r6r$rrr%�s�
�z Layer.fields.<locals>.<listcomp>�r-rKr$rr$r�fields�s
�zLayer.fieldscrQ)z�
        Return a list of the types of fields in this Layer.  For example,
        return the list [OFTInteger, OFTReal, OFTString] for an OGR layer that
        has an integer, a floating-point, and string fields.
        c	s$g|]}tt�t��j|���qSr)r
r�get_field_typerSrrTr$rrr%�s�z%Layer.field_types.<locals>.<listcomp>rUr$rr$r�field_types�s
�zLayer.field_typescrQ)z;Return a list of the maximum field widths for the features.c� g|]}t�t��j|���qSr)r�get_field_widthrSrrTr$rrr%���z&Layer.field_widths.<locals>.<listcomp>rUr$rr$r�field_widths��
�zLayer.field_widthscrQ)z-Return the field precisions for the features.crYr)r�get_field_precisionrSrrTr$rrr%�r[z*Layer.field_precisions.<locals>.<listcomp>rUr$rr$r�field_precisions�r]zLayer.field_precisionscCs.ztt�t�|j���WStyYdSw)N)r�geom_api�
clone_geomr�get_spatial_filterrrr$rrr�_get_spatial_filter�s
�zLayer._get_spatial_filtercCs�t|t�rt�|j|j�dSt|ttf�r5t|�dks td��t	t
|�\}}}}t�|j||||�dS|durBt�|jd�dStd��)N�z/Spatial filter list/tuple must have 4 elements.zJSpatial filter must be either an OGRGeometry instance, a 4-tuple, or None.)
r'rr�set_spatial_filterr�tuple�list�len�
ValueError�mapr�set_spatial_filter_rectr.)r�filter�xmin�ymin�xmax�ymaxrrr�_set_spatial_filter�s
zLayer._set_spatial_filtercs(�|jvrtd����fdd�|D�S)zg
        Return a list containing the given field name for every Feature
        in the Layer.
        zinvalid field name: %scsg|]}|����qSr)�get�r"r?��
field_namerrr%�r&z$Layer.get_fields.<locals>.<listcomp>)rVr)rrurrtr�
get_fields�s
zLayer.get_fieldsFcs0|rddlm��fdd�|D�Sdd�|D�S)zb
        Return a list containing the OGRGeometry for every Feature in
        the Layer.
        r��GEOSGeometrycsg|]}�|jj��qSr)r�wkbrsrwrrr%�sz#Layer.get_geoms.<locals>.<listcomp>cSsg|]}|j�qSr)rrsrrrr%�s)�django.contrib.gis.geosrx)r�geosrrwr�	get_geoms�szLayer.get_geomscCstt�|jt|���S)ah
        Return a bool indicating whether the this Layer supports the given
        capability (a string).  Valid capability strings include:
          'RandomRead', 'SequentialWrite', 'RandomWrite', 'FastSpatialFilter',
          'FastFeatureCount', 'FastGetExtent', 'CreateField', 'Transactions',
          'DeleteFeature', and 'FastSetNextByIndex'.
        )�boolrrrr)r�
capabilityrrrr�szLayer.test_capabilityN)r@)F)�__name__�
__module__�__qualname__�__doc__r r3r7r9r<r!�propertyrCr;r,rKrMrrVrXr\r_rcrq�spatial_filterrvr|rrrrrrsD







	



	rN) �ctypesrr�django.contrib.gis.gdal.baser� django.contrib.gis.gdal.enveloperr�django.contrib.gis.gdal.errorrr�django.contrib.gis.gdal.featurer	�django.contrib.gis.gdal.fieldr
�"django.contrib.gis.gdal.geometriesr� django.contrib.gis.gdal.geomtyper�"django.contrib.gis.gdal.prototypesr
rrr`rrO�django.contrib.gis.gdal.srsr�django.utils.encodingrrrrrrr�<module>s

https://t.me/RX1948 - 2025