| Server IP : 217.160.0.135 / Your IP : 216.73.217.85 Web Server : Apache System : Linux www 6.18.52-i1-ampere #1203 SMP Mon Sep 14 18:29:59 CEST 2026 aarch64 User : sws1074145052 ( 1074145052) PHP Version : 8.3.32 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /lib/python3/dist-packages/django/contrib/gis/gdal/__pycache__/ |
Upload File : |
�
�|�e� � � � d Z ddlmZ ddlmZ ddlmZ ddlmZ ddl m
Z
ddlmZ ddl
mZ dd lmZmZ G d
� de� � ZdS )
a�
DataSource is a wrapper for the OGR Data Source object, which provides
an interface for reading vector geometry data from many different file
formats (including ESRI shapefiles).
When instantiating a DataSource object, use the filename of a
GDAL-supported data source. For example, a SHP file or a
TIGER/Line file from the government.
The ds_driver keyword is used internally when a ctypes pointer
is passed in directly.
Example:
ds = DataSource('/home/foo/bar.shp')
for layer in ds:
for feature in layer:
# Getting the geometry for the feature.
g = feature.geom
# Getting the 'description' field for the feature.
desc = feature['description']
# We can also increment through all of the fields
# attached to this feature.
for field in feature:
# Get the name of the field (e.g. 'description')
nm = field.name
# Get the type (integer) of the field, e.g. 0 => OFTInteger
t = field.type
# Returns the value the field; OFTIntegers return ints,
# OFTReal returns floats, all else returns string.
val = field.value
� )�byref)�Path)�GDALBase)�Driver)�
GDALException)�Layer)�ds)�force_bytes� force_strc �f � e Zd ZdZej Zdd�Zd� Zd� Z d� Z
ed� � � Zed � � � Z
d
S )�
DataSourcez Wraps an OGR Data Source object.F�utf-8c �h � |rd| _ nd| _ || _ t j � � t |t
t f� � rjt j � � } t j t |� � | j t |� � � � }nq# t $ r t d|z � � �w xY wt || j � � rt |t j � � r|}nt dt |� � z � � �|r|| _ t |� � | _ d S t d|z � � �)N� r z%Could not open the datasource at "%s"z"Invalid data source input type: %szInvalid data source file "%s")�_write�encodingr �ensure_registered�
isinstance�strr �ptr_type�capi�open_dsr
r r �type�ptr�driver)�self�ds_input� ds_driver�writer r s �D/usr/lib/python3/dist-packages/django/contrib/gis/gdal/datasource.py�__init__zDataSource.__init__7 s; � �� ��D�K�K��D�K� ��
�� �"�"�"��h��d��,�,�
W���)�)�I�
X��\�+�h�"7�"7���e�I�FV�FV�W�W���� �
X�
X�
X� $�$K�h�$V�W�W�W�
X���� ��$�-�
0�
0� W�Z� �6�?�5[�5[� W��B�B�� D�t�H�~�~� U�V�V�V�
� L��D�H� ��+�+�D�K�K�K� � ?�(� J�K�K�Ks �5B �B/c �� � t |t � � rI t j | j t |� � � � }n�# t $ r t d|z � � �w xY wt |t � � rBd|cxk r| j k rn nt j
| j |� � }n1t d|z � � �t dt |� � z � � �t || � � S )z@Allows use of the index [] operator to get a layer at the index.z!Invalid OGR layer name given: %s.r z=Index out of range when accessing layers in a datasource: %s.zInvalid index type: %s)r r r �get_layer_by_namer r
r �
IndexError�int�layer_count� get_layer�_ptr� TypeErrorr r )r �index�layers r �__getitem__zDataSource.__getitem__X s� � ��e�S�!�!� D�
N��.�t�x��U�9K�9K�L�L���� �
N�
N�
N� �!D�u�!L�M�M�M�
N����
��s�
#�
#� D��E�,�,�,�,�D�,�,�,�,�,�,���t�y�%�8�8��� �!`�ch�!h�i�i�i��4�t�E�{�{�B�C�C�C��U�D�!�!�!s �'? �Ac � � | j S )z3Return the number of layers within the data source.)r&