| 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 : |
�
�|�eP] � �b � d Z ddlZddlmZ ddlmZmZmZmZm Z m
Z
ddlmZ ddl
mZmZ ddlmZmZ ddlmZ dd lmZmZ dd
lmZmZ ddlmZmZm Z ddl!m"Z" G d
� de� � Z# G d� de#� � Z$ G d� de#� � Z% G d� de%� � Z& G d� de#� � Z' G d� de#� � Z( G d� de(� � Z) G d� de(� � Z* G d� de(� � Z+de$d e%d!e'd"e)d#e*d$e+d%e(d&e&dej, z e$d ej, z e%d!ej, z e'd"ej, z e)d#ej, z e*d$ej, z e+d%ej, z e(iZ-dS )'a�
The OGRGeometry is a wrapper for using the OGR Geometry class
(see https://gdal.org/api/ogrgeometry_cpp.html#_CPPv411OGRGeometry).
OGRGeometry may be instantiated when reading geometries from OGR Data Sources
(e.g. SHP files), or when given OGC WKT (a string).
While the 'full' API is not present yet, the API is "pythonic" unlike
the traditional and "next-generation" OGR Python bindings. One major
advantage OGR Geometries have over their GEOS counterparts is support
for spatial reference systems and their transformation.
Example:
>>> from django.contrib.gis.gdal import OGRGeometry, OGRGeomType, SpatialReference
>>> wkt1, wkt2 = 'POINT(-90 30)', 'POLYGON((0 0, 5 0, 5 5, 0 5)'
>>> pnt = OGRGeometry(wkt1)
>>> print(pnt)
POINT (-90 30)
>>> mpnt = OGRGeometry(OGRGeomType('MultiPoint'), SpatialReference('WGS84'))
>>> mpnt.add(wkt1)
>>> mpnt.add(wkt1)
>>> print(mpnt)
MULTIPOINT (-90 30,-90 30)
>>> print(mpnt.srs.name)
WGS 84
>>> print(mpnt.srs.proj)
+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs
>>> mpnt.transform(SpatialReference('NAD27'))
>>> print(mpnt.proj)
+proj=longlat +ellps=clrk66 +datum=NAD27 +no_defs
>>> print(mpnt)
MULTIPOINT (-89.999930378602485 29.999797886557641,-89.999930378602485 29.999797886557641)
The OGRGeomType class is to make it easy to specify an OGR geometry type:
>>> from django.contrib.gis.gdal import OGRGeomType
>>> gt1 = OGRGeomType(3) # Using an integer for the type
>>> gt2 = OGRGeomType('Polygon') # Using a string
>>> gt3 = OGRGeomType('POLYGON') # It's case-insensitive
>>> print(gt1 == 3, gt1 == 'Polygon') # Equivalence works w/non-OGRGeomType objects
True True
� N)�b2a_hex)�byref�c_char_p�c_double�c_ubyte�c_void_p� string_at)�GDALBase)�Envelope�OGREnvelope)�
GDALException�SRSException)�OGRGeomType)�geom�srs)�CoordTransform�SpatialReference)� hex_regex�
json_regex� wkt_regex)�force_bytesc � � e Zd ZdZej Zd@d�Zd� Zd� Z e
d� � � Zed� � � Z
e
d� � � Zed � � � Ze
d
� � � Zd� Zd� Zd
� Zd� Zd� Zd� Zed� � � Zd� Zd� Z eee� � Zed� � � Zed� � � Zed� � � Zed� � � Zed� � � Z ed� � � Z!ed� � � Z"ed� � � Z#ed� � � Z$ed� � � Z%d� Z&d� Z' ee&e'� � Z(d � Z)d!� Z* ee)e*� � Z+d"� Z,ed#� � � Z-ed$� � � Z.ed%� � � Z/ed&� � � Z0e0Z1ed'� � � Z2ed(� � � Z3ed)� � � Z4ed*� � � Z5ed+� � � Z6d,� Z7d-� Z8dAd/�Z9d0� Z:d1� Z;d2� Z<d3� Z=d4� Z>d5� Z?d6� Z@d7� ZAd8� ZBd@d9�ZCed:� � � ZDed;� � � ZEd<� ZFd=� ZGd>� ZHd?� ZIdS )B�OGRGeometryzEncapsulate an OGR geometry.Nc � � t |t � � }|r=t j |� � r)t t
� |� � � � }d}|�r�t j |� � }t j |� � }|�r|d rt |d � � }|d �
� � dk rut j t |d � � j � � }t j |t! t# |d � � � � � � � � � �nSt j t! t# |d � � � � � � � dt! t) � � � � � � }n�|r(| � |� � � � � }n�t |� � t j t |� � j � � }n�t |t � � r| � |� � }nft |t � � rt j |j � � }n7t || j � � r|}nt1 dt3 |� � z � � �|st1 d|z � � �|| _ |r|| _ t8 | j j | _ dS ) z=Initialize Geometry on either WKT or an OGR pointer as input.F�srid�type�
LINEARRING�wktNz4Invalid input type for OGR Geometry construction: %sz)Cannot create OGR Geometry from input: %s)�
isinstance�strr �match�
memoryview�bytes�fromhexr r �int�upper�capi�create_geomr �num�
import_wktr r �encode�from_wktr �
_from_json� _from_wkb�ptr_typer
r �ptrr �GEO_CLASSES� geom_type� __class__)�self�
geom_inputr �str_instance�wkt_m�json_m�gs �D/usr/lib/python3/dist-packages/django/contrib/gis/gdal/geometries.py�__init__zOGRGeometry.__init__? sz � �!�*�c�2�2�� � !�I�O�J�7�7� !�#�E�M�M�*�$=�$=�>�>�J� �L� � k��O�J�/�/�E��%�j�1�1�F��
B���=� -��e�F�m�,�,�C���=�&�&�(�(�L�8�8� �(��U�6�]�)C�)C�)G�H�H�A��O�A�u�X�e�E�l�6I�6I�6K�6K�-L�-L�'M�'M�N�N�N�N��
�e�H�U�5�\�5H�5H�5J�5J�,K�,K�&L�&L�d�TY�Zb�Zd�Zd�Te�Te�f�f�A�A��
B��O�O�J�$5�$5�$7�$7�8�8��� �J�'�'�'��$�[��%<�%<�%@�A�A���
�
�J�
/�
/�
k����z�*�*�A�A�
�
�K�
0�
0� k�� ���0�0�A�A�
�
�D�M�
2�
2� k��A�A�� V�Y]�^h�Yi�Yi� i�j�j�j� � Z�� K�j� X�Y�Y�Y���� � ��D�H� %�T�^�%7�8����� c �T � | j }|r|j }nd }t | j � � |fS �N)r r r# �wkb�r4 r s r: �__getstate__zOGRGeometry.__getstate__x s2 � ��h��� ��'�C�C��C��T�X����#�#r<