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 : |
o �a� � @ s| d Z ddlmZ ddlmZ ddlmZ ddlmZ ddl m Z ddlmZ ddl mZ dd lmZmZ G d 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 @ sP e Zd ZdZejZddd�Zdd� Zdd � Z d d� Z edd � �Zedd� �Z dS )� DataSourcez Wraps an OGR Data Source object.F�utf-8c C s� |rd| _ nd| _ || _t�� t|ttf�r7t�� }zt� t |�| j t|��}W n$ ty6 td| ��w t|| j�rFt|tj�rF|}ntdt |� ��|rZ|| _t|�| _d S td| ��)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 � r �D/usr/lib/python3/dist-packages/django/contrib/gis/gdal/datasource.py�__init__7 s&