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 �aP] � @ s� d Z ddlZddlmZ ddlmZmZmZmZm Z m Z ddlmZ ddl mZmZ ddlmZmZ ddlmZ dd lmZmZ dd lmZmZ ddlmZmZm Z ddl!m"Z" G d d� de�Z#G dd� de#�Z$G dd� de#�Z%G dd� de%�Z&G dd� de#�Z'G dd� de#�Z(G dd� de(�Z)G dd� de(�Z*G dd� de(�Z+de$d e%d!e'd"e)d#e*d$e+d%e(d&e&dej, e$d ej, e%d!ej, e'd"ej, e)d#ej, e*d$ej, e+d%ej, 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 @ s� e Zd ZdZejZd|dd�Zdd� Zdd� Z e d d � �Zedd� �Z e d d� �Zedd� �Ze dd� �Zdd� Zdd� Zdd� Zdd� Zdd� Zdd� Zedd � �Zd!d"� Zd#d$� Zeee�Zed%d&� �Zed'd(� �Zed)d*� �Zed+d,� �Zed-d.� �Z ed/d0� �Z!ed1d2� �Z"ed3d4� �Z#ed5d6� �Z$ed7d8� �Z%d9d:� Z&d;d<� Z'ee&e'�Z(d=d>� Z)d?d@� Z*ee)e*�Z+dAdB� Z,edCdD� �Z-edEdF� �Z.edGdH� �Z/edIdJ� �Z0e0Z1edKdL� �Z2edMdN� �Z3edOdP� �Z4edQdR� �Z5edSdT� �Z6dUdV� Z7dWdX� Z8d}dZd[�Z9d\d]� Z:d^d_� Z;d`da� Z<dbdc� Z=ddde� Z>dfdg� Z?dhdi� Z@djdk� ZAdldm� ZBd|dndo�ZCedpdq� �ZDedrds� �ZEdtdu� ZFdvdw� ZGdxdy� ZHdzd{� ZIdS )~�OGRGeometryzEncapsulate an OGR geometry.Nc C sr t |t�}|rt�|�rtt�|��}d}|rxt�|�}t�|�}|ra|d r-t |d �}|d � � dkrNt�t |d �j�}t�|tt|d �� ��� nRt�tt|d �� ��dtt� ��}n?|rk| �|�� �}n5t |� t�t |�j�}n(t |t�r�| �|�}nt |t �r�t�|j�}nt || j�r�|}ntdt|� ��|s�td| ��|| _|r�|| _t| jj | _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�g� r7 �D/usr/lib/python3/dist-packages/django/contrib/gis/gdal/geometries.py�__init__? s>