OwlCyberSecurity - MANAGER
Edit File: geometries.cpython-39.pyc
a jH�f_ � @ s� d Z ddlZddlmZ ddlmZmZmZmZm Z m Z ddlmZ ddl mZmZ ddlmZmZ ddlmZ dd lmZ dd lmZ ddlmZmZ ddlmZmZm Z dd l!m"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*G dd� de(�Z+d e$d!e%d"e'd#e)d$e*d%e+d&e(d'e&d ej, 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.99993037860248 29.99979788655764,-89.99993037860248 29.99979788655764) 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 s| t |t�}|r*t�|�r*tt�|��}d}|r�t�|�}t�|�}|r�|d rZt |d �}|d � � dkr�t�t |d �j�}t�|tt|d �� ��� q�t�tt|d �� ��dtt� ��}n,|r�| �|�� �}nt |� t�t |�j�}nVt |t��r| �|�}n>t |t ��r"t�|j�}n$t || j��r6|}ntdt|� ��|�sXtd| ��|| _|�rj|| _t| jj | _dS ) z=Initialize Geometry on either WKT or an OGR pointer as input.F�srid�typeZ 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 �numZ import_wktr r �encodeZfrom_wktr � _from_json� _from_wkbZptr_typer r �ptrr �GEO_CLASSES� geom_type� __class__)�self� geom_inputr Zstr_instanceZwkt_mZjson_m�g� r0 �d/home/gouroczh/virtualenv/test/3.9/lib/python3.9/site-packages/django/contrib/gis/gdal/geometries.py�__init__A sN ����zOGRGeometry.__init__c C s$ | j }|r|j}nd }t| j�|fS �N)r r r �wkb�r- r r0 r0 r1 �__getstate__� s zOGRGeometry.__getstate__c C s>