File manager - Edit - /usr/local/CyberCP/lib/python3.10/site-packages/django/contrib/gis/geos/__pycache__/geometry.cpython-310.pyc
Back
o �h2g � @ s d Z ddlZddlmZmZmZ ddlmZ ddlm Z m Z mZ ddlm Z ddlmZ ddlmZ dd lmZ dd lmZmZ ddlmZ ddlmZ dd lmZmZmZm Z m!Z! ddl"m#Z# ddl$m%Z%m&Z& G dd� de�Z'G dd� d�Z(e#G dd� de'e��Z)dS )zh This module contains the 'base' GEOSGeometry object -- all GEOS Geometries inherit from this object. � N)� addressof�byref�c_double)�gdal)� hex_regex� json_regex� wkt_regex)� prototypes)�GEOSBase)�GEOSCoordSeq)� GEOSException)�GEOM_PTR�geos_version_tuple)� ListMixin��PreparedGeometry)�ewkb_w�wkb_r�wkb_w�wkt_r�wkt_w)�deconstructible)�force_bytes� force_strc @ sb e Zd ZdZeZejZdZ dd� Z dd� Zdd� Zd d � Z dd� Zd d� Zdd� Zdd� Zdd� Zdd� Zedd� �Zedd� �Zedd� �Zedd� �Zdd � Zd!d"� Zd#d$� Zd%d&� Zd'd(� Zd)d*� Ze d+d,� �Z!e d-d.� �Z"e d/d0� �Z#e d1d2� �Z$e d3d4� �Z%e d5d6� �Z&e d7d8� �Z'd�d9d:�Z(d;d<� Z)e d=d>� �Z*e d?d@� �Z+e dAdB� �Z,e dCdD� �Z-e dEdF� �Z.e dGdH� �Z/dIdJ� Z0dKdL� Z1dMdN� Z2dOdP� Z3dQdR� Z4d�dTdU�Z5dVdW� Z6dXdY� Z7dZd[� Z8d\d]� Z9d^d_� Z:e d`da� �Z;e;j<dbda� �Z;e dcdd� �Z=e dedf� �Z>e dgdh� �Z?e didj� �Z@e dkdl� �ZAeAZBe dmdn� �ZCe dodp� �ZDe dqdr� �ZEe dsdt� �ZFdudv� ZGe dwdx� �ZHe dydz� �ZIe d{d|� �ZJd�d}d~�ZKdd�� ZLe d�d�� �ZMd�d�d��ZN �d�d�d��ZOe d�d�� �ZPe d�d�� �ZQd�d�� ZRe d�d�� �ZSd�d�� ZTe d�d�� �ZUd�d�� ZVd�d�d��ZWd�d�� ZXe d�d�� �ZYd�d�� ZZe d�d�� �Z[d�d�� Z\e d�d�� �Z]e d�d�� �Z^d�d�� Z_dS )��GEOSGeometryBaseNFc C s� || _ t| �ttfv rI|d u rFtjd u r@ddlm}m}m}m } ddl m}m} ddl m} ddlm} | ||| ||||d�t_tj| j }|| _| �� d S )N� )�GeometryCollection�MultiLineString� MultiPoint�MultiPolygon)� LinearRing� LineString��Point)�Polygon)r r � � � � � � )�_ptr�typer �GEOSGeometry� _GEOS_CLASSES�collectionsr r r r � linestringr r! �pointr# �polygonr$ �geom_typeid� __class__� _post_init)�self�ptr�clsr r r r r r! r# r$ � r9 �S/usr/local/CyberCP/lib/python3.10/site-packages/django/contrib/gis/geos/geometry.py�__init__ s( � zGEOSGeometryBase.__init__c C s* | j rtt�| j�| j�| _dS d| _dS )z"Perform post-initialization setup.N)�has_csr �capi�get_csr7 �hasz�_cs�r6 r9 r9 r: r5 = s ��zGEOSGeometryBase._post_initc C � | � � S )z� Return a clone because the copy of a GEOSGeometry may contain an invalid pointer location if the original is garbage collected. ��clonerA r9 r9 r: �__copy__E � zGEOSGeometryBase.__copy__c C rB )z� The `deepcopy` routine is used by the `Node` class of django.utils.tree; thus, the protocol routine needs to be implemented to return correct copies (clones) of these GEOS objects, which use C pointers. rC )r6 �memodictr9 r9 r: �__deepcopy__L � zGEOSGeometryBase.__deepcopy__c C � | j S )z+EWKT is used for the string representation.)�ewktrA r9 r9 r: �__str__T s zGEOSGeometryBase.__str__c C s d| j tt| j��f S )z8Short-hand representation because WKT may be very large.z<%s object at %s>)� geom_type�hexr r7 rA r9 r9 r: �__repr__X s zGEOSGeometryBase.__repr__c C s t | j�S �N)�bytes�wkbrA r9 r9 r: �_to_pickle_wkb] s zGEOSGeometryBase._to_pickle_wkbc C s t � �t|��S rP )r �read� memoryview)r6 rR r9 r9 r: �_from_pickle_wkb` � z!GEOSGeometryBase._from_pickle_wkbc C s | � � | jfS rP )rS �sridrA r9 r9 r: �__getstate__c s zGEOSGeometryBase.__getstate__c C s6 |\}}| � |�}|std��|| _| �� || _d S )Nz+Invalid Geometry loaded from pickled state.)rV r r7 r5 rX )r6 �staterR rX r7 r9 r9 r: �__setstate__h s zGEOSGeometryBase.__setstate__c C s t � �|�S rP )r rT )r8 rR r9 r9 r: � _from_wkbr � zGEOSGeometryBase._from_wkbc C st t | �} d }| �dd�}t|�dkr)|\}}t�d|�}|s"td��t|d �}n| }|s1td��tt�|�|d�S ) N� ;r r% s SRID=(?P<srid>\-?\d+)zEWKT has invalid SRID part.rX z%Expected WKT but got an empty string.�rX ) r �split�len�re�match� ValueError�intr- � _from_wkt)rK rX �parts� srid_part�wktrc r9 r9 r: � from_ewktv s zGEOSGeometryBase.from_ewktc C s t � �| �S rP )r rT )ri r9 r9 r: rf � r] zGEOSGeometryBase._from_wktc C s t j�|�jS rP )r �OGRGeometry�from_gml�geos)r8 � gml_stringr9 r9 r: rl � � zGEOSGeometryBase.from_gmlc C sR t |t�rzt�|�}W n ttfy Y dS w t |t�o(| j|jko(| �|�S )zz Equivalence testing, a Geometry may be compared with another Geometry or an EWKT representation. F)� isinstance�strr- rj rd r rX �equals_exact�r6 �otherr9 r9 r: �__eq__� s � ��zGEOSGeometryBase.__eq__c C s t | j| jf�S rP )�hashrX ri rA r9 r9 r: �__hash__� rW zGEOSGeometryBase.__hash__c C � | � |�S )z0Return the union of this Geometry and the other.)�unionrs r9 r9 r: �__or__� � zGEOSGeometryBase.__or__c C rx )z7Return the intersection of this Geometry and the other.)�intersectionrs r9 r9 r: �__and__� r{ zGEOSGeometryBase.__and__c C rx )z2Return the difference this Geometry and the other.)� differencers r9 r9 r: �__sub__� r{ zGEOSGeometryBase.__sub__c C rx )z?Return the symmetric difference of this Geometry and the other.)�sym_differencers r9 r9 r: �__xor__� r{ zGEOSGeometryBase.__xor__c C s | j r| j�� S dS )z<Return a clone of the coordinate sequence for this Geometry.N)r<