
    hk                        S r SSKrSSKrSSKJr  SSKJrJrJrJ	r	J
r
Jr  SSKJr  SSKJrJr  SSKJrJr  SSKJr  SS	KJr  SS
KJr  SSKJrJr  SSKJrJ r J!r!  SSK"J#r#  SSK$J%r%   " S S\5      r& " S S\&5      r' " S S\&5      r( " S S\(5      r) " S S\&5      r* " S S\&5      r+ " S S\+5      r, " S S\+5      r- " S S \+5      r.0 S!\'_S"\(_S#\*_S$\,_S%\-_S&\._S'\+_S(\)_S)\'_S*\(_S+\*_S,\,_S-\-_S.\._S/\+_S0\'_S1\(_S2\*S3\,S4\-S5\.S6\+S!\R^                  -   \'S"\R^                  -   \(S#\R^                  -   \*S$\R^                  -   \,S%\R^                  -   \-S&\R^                  -   \.S'\R^                  -   \+0Er0g)7ah  
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)RemovedInDjango60Warning)force_bytesc                   >   \ rS rSrSr\R                  rSFS jrS r	S r
\S 5       r\S 5       r\S	 5       r\S
 5       r\S 5       rS rS rS rS rS rS r\S 5       r\S 5       r\R6                  S 5       r\S 5       r\S 5       r\S 5       r\S 5       r\S 5       r \S 5       r!\S 5       r"\S 5       r#\S 5       r$\S 5       r%\S 5       r&S  r'\S! 5       r(S" r)S# r*S$ r+\" \*\+5      r,S% r-S& r.\" \-\.5      r/S' r0\S( 5       r1\S) 5       r2\S* 5       r3\S+ 5       r4\4r5\S, 5       r6\S- 5       r7\S. 5       r8\S/ 5       r9\S0 5       r:S1 r;S2 r<SGS3 jr=S4 r>S5 r?S6 r@S7 rAS8 rBS9 rCS: rDS; rES< rFSFS= jrG\S> 5       rH\S? 5       rIS@ rJSA rKSB rLSC rM\SD 5       rNSErOg)HOGRGeometry?   zEncapsulate an OGR geometry.Nc           	         [        U[        5      nU(       a;  [        R                  " U5      (       a   [	        [
        R                  U5      5      nSnU(       Gas  [        R                  " U5      n[        R                  " U5      nU(       a  US   (       a  [        US   5      nUS   R                  5       S:X  ah  [        R                  " [        US   5      R                  5      n[        R                  " U[!        [#        US   R%                  5       5      5      5        GO:[        R&                  " [!        [#        US   R%                  5       5      5      S[!        [)        5       5      5      nOU(       a   U R+                  UR%                  5       5      nO[        U5        [        R                  " [        U5      R                  5      nO[        U[        5      (       a  U R-                  U5      nOj[        U[        5      (       a!  [        R                  " UR                  5      nO4[        XR.                  5      (       a  UnO[1        S[3        U5      -  5      eU(       d  [1        SU-  5      eX`l        U(       a  X l        [8        R;                  U R<                  R                  5      =nc  [?        S	U R<                   35      eXpl         g)
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: %szUnsupported geometry type: )!
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get	geom_type	TypeError	__class__)self
geom_inputr   str_instancewkt_mjson_mg	geo_classs           T/var/www/html/env/lib/python3.13/site-packages/django/contrib/gis/gdal/geometries.py__init__OGRGeometry.__init__D   s   !*c2 IOOJ77#EMM*$=>J L OOJ/E%%j1F=eFm,C=&&(L8 ((U6])C)G)GHAOOAuXeEl6I6I6K-L'MNhuU|':':'<=>eHJFWA OOJ$5$5$78 J'$$[%<%@%@A
J//z*A
K00  0A
MM22AFz"#  ;jH   H %););<<IE9$..9IJKK"    c                 t    U R                   nU(       a  UR                  nOS n[        U R                  5      U4$ N)r   r    r%   wkbr8   r   s     r?   __getstate__OGRGeometry.__getstate__   s/    hh''CCTXX##rB   c                     Uu  p#[         R                  " US [        [        5       5      [	        U5      5      nU(       d  [        S5      eX@l        X0l        g )Nz.Invalid OGRGeometry loaded from pickled state.)r)   from_wkbr   r   lenr   r2   r   )r8   staterE   r   r2   s        r?   __setstate__OGRGeometry.__setstate__   sA    mmCuXZ'8#c(C PQQrB   c                 z    [         R                  " [        U5      S [        [	        5       5      [        U5      5      $ rD   )r)   rJ   r%   r   r   rK   )clsr9   s     r?   r0   OGRGeometry._from_wkb   s,    }}*tU8:%6J
 	
rB   c                 .    [         R                  " U 5      $ rD   )r)   	from_jsonr9   s    r?   r/   OGRGeometry._from_json   s    ~~j))rB   c                 t    Uu  p#pE[        SU< SU< SU< SU< SU< SU< SU< SU< SU< SU< S35      $ )z2Construct a Polygon from a bounding box (4-tuple).z	POLYGON(( z, z)))r   )rP   bboxx0y0x1y1s         r?   	from_bboxOGRGeometry.from_bbox   s4     2r2r2r2r27
 	
rB   c                 P    [        [         R                  [        U 5      5      5      $ rD   )r   r/   r   rT   s    r?   rS   OGRGeometry.from_json   s    ;11+j2IJKKrB   c                 L    U " [         R                  " [        U5      5      5      $ rD   )r)   from_gmlr   )rP   
gml_strings     r?   rb   OGRGeometry.from_gml   s    4==Z!89::rB   c                 $    U R                  U5      $ )z'Return the union of the two geometries.)unionr8   others     r?   __or__OGRGeometry.__or__   s    zz%  rB   c                 $    U R                  U5      $ )z7Return the intersection of this Geometry and the other.)intersectionrg   s     r?   __and__OGRGeometry.__and__   s      ''rB   c                 $    U R                  U5      $ )z2Return the difference this Geometry and the other.)
differencerg   s     r?   __sub__OGRGeometry.__sub__   s    u%%rB   c                 $    U R                  U5      $ )z?Return the symmetric difference of this Geometry and the other.)sym_differencerg   s     r?   __xor__OGRGeometry.__xor__   s    ""5))rB   c                 R    [        U[        5      =(       a    U R                  U5      $ )z$Is this Geometry equal to the other?)r!   r   equalsrg   s     r?   __eq__OGRGeometry.__eq__   s    %-D$++e2DDrB   c                     U R                   $ )z*WKT is used for the string representation.)r    r8   s    r?   __str__OGRGeometry.__str__   s    xxrB   c                 B    [         R                  " U R                  5      $ )z5Return 0 for points, 1 for lines, and 2 for surfaces.)r)   get_dimsr2   r|   s    r?   	dimensionOGRGeometry.dimension        }}TXX&&rB   c                 B    [         R                  " U R                  5      $ )z0Return the coordinate dimension of the Geometry.)r)   get_coord_dimr2   r|   s    r?   	coord_dimOGRGeometry.coord_dim        !!$((++rB   c                     Sn[         R                  " U[        SS9  US;  a  [        S5      e[        R
                  " U R                  U5        g)z.Set the coordinate dimension of this Geometry.z5coord_dim setter is deprecated. Use set_3d() instead.   )
stacklevel)r      z(Geometry dimension must be either 2 or 3N)warningswarnr   
ValueErrorr)   set_coord_dimr2   )r8   dimmsgs      r?   r   r      sC     Fc3BfGHH488S)rB   c                 B    [         R                  " U R                  5      $ )z/Return the number of elements in this Geometry.)r)   get_geom_countr2   r|   s    r?   
geom_countOGRGeometry.geom_count   s     ""488,,rB   c                 B    [         R                  " U R                  5      $ )z-Return the number of Points in this Geometry.)r)   get_point_countr2   r|   s    r?   point_countOGRGeometry.point_count   s     ##DHH--rB   c                     U R                   $ )z7Alias for `point_count` (same name method in GEOS API.)r   r|   s    r?   
num_pointsOGRGeometry.num_points        rB   c                     U R                   $ )zAlias for `point_count`.r   r|   s    r?   
num_coordsOGRGeometry.num_coords   r   rB   c                 T    [        [        R                  " U R                  5      5      $ )z"Return the Type for this Geometry.)r   r)   get_geom_typer2   r|   s    r?   r5   OGRGeometry.geom_type   s     4--dhh788rB   c                 B    [         R                  " U R                  5      $ )z!Return the Name of this Geometry.)r)   get_geom_namer2   r|   s    r?   	geom_nameOGRGeometry.geom_name   r   rB   c                 B    [         R                  " U R                  5      $ )zHReturn the area for a LinearRing, Polygon, or MultiPolygon; 0 otherwise.)r)   get_arear2   r|   s    r?   areaOGRGeometry.area  r   rB   c           	      x    [        [        R                  " U R                  [	        [        5       5      5      5      $ )z&Return the envelope for this Geometry.)r   r)   get_enveloper2   r   r   r|   s    r?   envelopeOGRGeometry.envelope  s'     ))$((E+-4HIJJrB   c                 B    [         R                  " U R                  5      $ rD   )r)   is_emptyr2   r|   s    r?   emptyOGRGeometry.empty  s    }}TXX&&rB   c                 .    U R                   R                  $ )zCReturn the envelope as a 4-tuple, instead of as an Envelope object.)r   tupler|   s    r?   extentOGRGeometry.extent  s     }}"""rB   c                 B    [         R                  " U R                  5      $ )z.Return True if the geometry has Z coordinates.)r)   is_3dr2   r|   s    r?   r   OGRGeometry.is_3d  s     zz$((##rB   c                     USL a"  [         R                  " U R                  S5        gUSL a"  [         R                  " U R                  S5        g[        SU< S35      e)z'Set if this geometry has Z coordinates.T   Fr   z*Input to 'set_3d' must be a boolean, got ''.N)r)   set_3dr2   r   r8   values     r?   r   OGRGeometry.set_3d  sJ    D=KK!$e^KK!$I%RTUVVrB   c                 B    [         R                  " U R                  5      $ )z.Return True if the geometry has M coordinates.)r)   is_measuredr2   r|   s    r?   r   OGRGeometry.is_measured#       ))rB   c                     USL a"  [         R                  " U R                  S5        gUSL a"  [         R                  " U R                  S5        g[        SU< S35      e)z'Set if this geometry has M coordinates.Tr   Fr   z0Input to 'set_measured' must be a boolean, got 'r   N)r)   set_measuredr2   r   r   s     r?   r   OGRGeometry.set_measured(  sQ    D=dhh*e^dhh*B5)2N rB   c                      [         R                  " U R                  5      n[        [        R
                  " U5      5      $ ! [         a     gf = f)z/Return the Spatial Reference for this Geometry.N)r)   get_geom_srsr2   r   srs_api	clone_srsr   )r8   srs_ptrs     r?   _get_srsOGRGeometry._get_srs6  sC    	''1G#G$5$5g$>?? 		s   >A 
AAc                 *   [        U[        5      (       a  UR                  nOP[        U[        [        45      (       a  [        U5      nUR                  nOUc  SnO[        S[        U5      -  5      e[        R                  " U R                  U5        g)z+Set the SpatialReference for this geometry.Nz7Cannot assign spatial reference with object of type: %s)	r!   r   r2   r'   r"   r6   r   r)   
assign_srs)r8   r   r   srs       r?   _set_srsOGRGeometry._set_srs>  sw     c+,,ggGc3Z((!#&BffG[GIDQTIU  	'*rB   c                 B    U R                   nU(       a  UR                  $ g rD   )r   r   rF   s     r?   	_get_sridOGRGeometry._get_sridT  s    hh88OrB   c                 V    [        U[        5      (       d  Uc  Xl        g [        S5      e)Nz!SRID must be set with an integer.)r!   r'   r   r6   )r8   r   s     r?   	_set_sridOGRGeometry._set_sridZ  s$    dC  DLH?@@rB   c                 D    SSK Jn  UR                  U R                  5      $ )Nr   GEOSGeometry)django.contrib.gis.geosr   r0   rE   r8   r   s     r?   	_geos_ptrOGRGeometry._geos_ptrc  s    8%%dhh//rB   c                 P    SSK Jn  U" U R                  5       U R                  5      $ )z3Return a GEOSGeometry object from this OGRGeometry.r   r   )r   r   r   r   r   s     r?   geosOGRGeometry.geosh  s     	9DNN,dii88rB   c                 B    [         R                  " U R                  5      $ )z.Return the GML representation of the Geometry.)r)   to_gmlr2   r|   s    r?   gmlOGRGeometry.gmlo  s     {{488$$rB   c                 H    [        U R                  5      R                  5       $ )z<Return the hexadecimal representation of the WKB (a string).)r   rE   r(   r|   s    r?   hexOGRGeometry.hext  s     txx &&((rB   c                 B    [         R                  " U R                  5      $ )z5
Return the GeoJSON representation of this Geometry.
)r)   to_jsonr2   r|   s    r?   jsonOGRGeometry.jsony  s    
 ||DHH%%rB   c                 D    [         R                  " U R                  S5      $ )z.Return the KML representation of the Geometry.N)r)   to_kmlr2   r|   s    r?   kmlOGRGeometry.kml  s     {{488T**rB   c                 B    [         R                  " U R                  5      $ )z"Return the size of the WKB buffer.)r)   get_wkbsizer2   r|   s    r?   wkb_sizeOGRGeometry.wkb_size  r   rB   c                 ,   [         R                  S:X  a  SnOSnU R                  n[        U-  " 5       nU R                  (       a  [
        R                  O[
        R                  nU" U R                  U[        U5      5        [        [        X25      5      $ )z.Return the WKB representation of the Geometry.littler   r   )sys	byteorderr   r   r   r)   
to_iso_wkbto_wkbr2   r   r$   r	   )r8   r   szbufr   s        r?   rE   OGRGeometry.wkb  sl     ==H$II]]| %)$4$4$++txxE#J/)C,--rB   c                     U R                   (       a  [        R                  O[        R                  nU" U R                  [        [        5       5      5      $ )z.Return the WKT representation of the Geometry.)r   r)   
to_iso_wktto_wktr2   r   r   )r8   r  s     r?   r    OGRGeometry.wkt  s3     %)$4$4$++dhhhj 122rB   c                     U R                   nU(       a/  UR                  (       a  SUR                  < SU R                  < 3$ U R                  $ )z/Return the EWKT representation of the Geometry.zSRID=;)r   r   r    rF   s     r?   ewktOGRGeometry.ewkt  s4     hh3888#&88TXX6688OrB   c                 j    [        [        R                  " U R                  5      U R                  5      $ )zClone this OGR Geometry.)r   r)   
clone_geomr2   r   r|   s    r?   cloneOGRGeometry.clone  s     4??4884dhh??rB   c                 D    [         R                  " U R                  5        g)z
If there are any rings within this geometry that have not been
closed, this routine will do so by adding the starting point at the
end.
N)r)   geom_close_ringsr2   r|   s    r?   close_ringsOGRGeometry.close_rings  s     	dhh'rB   c                    U(       a#  U R                  5       nUR                  U5        U$ [        U[        5      (       a,  [        R
                  " U R                  UR                  5        g[        U[        5      (       a,  [        R                  " U R                  UR                  5        g[        U[        [        45      (       a7  [        U5      n[        R                  " U R                  UR                  5        g[        S5      e)aA  
Transform this geometry to a different spatial reference system.
May take a CoordTransform object, a SpatialReference object, string
WKT or PROJ, and/or an integer SRID.  By default, return nothing
and transform the geometry in-place. However, if the `clone` keyword is
set, return a transformed clone of this geometry.
zUTransform only accepts CoordTransform, SpatialReference, string, and integer objects.N)r  	transformr!   r   r)   geom_transformr2   r   geom_transform_tor'   r"   r6   )r8   coord_transr  kloner   s        r?   r  OGRGeometry.transform  s     JJLEOOK(L k>22+//:%566""488[__=c3Z00!+.B""488RVV4A rB   c                 |    [        U[        5      (       d  [        S5      eU" U R                  UR                  5      $ )zyA generalized function for topology operations, takes a GDAL function and
the other geometry to perform the operation on.z<Must use another OGRGeometry object for topology operations!)r!   r   r6   r2   )r8   funcrh   s      r?   	_topologyOGRGeometry._topology  s8     %--N  DHHeii((rB   c                 B    U R                  [        R                  U5      $ )z7Return True if this geometry intersects with the other.)r  r)   ogr_intersectsrg   s     r?   
intersectsOGRGeometry.intersects  s    ~~d11599rB   c                 B    U R                  [        R                  U5      $ )z8Return True if this geometry is equivalent to the other.)r  r)   
ogr_equalsrg   s     r?   rx   OGRGeometry.equals      ~~doou55rB   c                 B    U R                  [        R                  U5      $ )zBReturn True if this geometry and the other are spatially disjoint.)r  r)   ogr_disjointrg   s     r?   disjointOGRGeometry.disjoint      ~~d//77rB   c                 B    U R                  [        R                  U5      $ )z/Return True if this geometry touches the other.)r  r)   ogr_touchesrg   s     r?   touchesOGRGeometry.touches      ~~d..66rB   c                 B    U R                  [        R                  U5      $ )z/Return True if this geometry crosses the other.)r  r)   ogr_crossesrg   s     r?   crossesOGRGeometry.crosses  r/  rB   c                 B    U R                  [        R                  U5      $ )z1Return True if this geometry is within the other.)r  r)   
ogr_withinrg   s     r?   withinOGRGeometry.within  r%  rB   c                 B    U R                  [        R                  U5      $ )z0Return True if this geometry contains the other.)r  r)   ogr_containsrg   s     r?   containsOGRGeometry.contains  r*  rB   c                 B    U R                  [        R                  U5      $ )z0Return True if this geometry overlaps the other.)r  r)   ogr_overlapsrg   s     r?   overlapsOGRGeometry.overlaps  r*  rB   c                     [        U[        5      (       a1  [        U" U R                  UR                  5      U R                  5      $ [        U" U R                  5      U R                  5      $ )z?A helper routine for the OGR routines that generate geometries.)r!   r   r2   r   )r8   gen_funcrh   s      r?   _geomgenOGRGeometry._geomgen  sI    e[))x%))<dhhGGx1488<<rB   c                 @    U R                  [        R                  5      $ )z%Return the boundary of this geometry.)rB  r)   get_boundaryr|   s    r?   boundaryOGRGeometry.boundary  s     }}T..//rB   c                 @    U R                  [        R                  5      $ )zS
Return the smallest convex Polygon that contains all the points in
this Geometry.
)rB  r)   geom_convex_hullr|   s    r?   convex_hullOGRGeometry.convex_hull  s     }}T2233rB   c                 B    U R                  [        R                  U5      $ )zh
Return a new geometry consisting of the region which is the difference
of this geometry and the other.
)rB  r)   	geom_diffrg   s     r?   rp   OGRGeometry.difference  s    
 }}T^^U33rB   c                 B    U R                  [        R                  U5      $ )z`
Return a new geometry consisting of the region of intersection of this
geometry and the other.
)rB  r)   geom_intersectionrg   s     r?   rl   OGRGeometry.intersection#  s    
 }}T33U;;rB   c                 B    U R                  [        R                  U5      $ )zY
Return a new geometry which is the symmetric difference of this
geometry and the other.
)rB  r)   geom_sym_diffrg   s     r?   rt   OGRGeometry.sym_difference*  s    
 }}T//77rB   c                 B    U R                  [        R                  U5      $ )zc
Return a new geometry consisting of the region which is the union of
this geometry and the other.
)rB  r)   
geom_unionrg   s     r?   rf   OGRGeometry.union1  s    
 }}T__e44rB   c                     [        [        S5      5      n[        R                  " U R                  UR                  5        U$ )z.Return the centroid (a Point) of this Polygon.Point)r   r   r)   get_centroidr2   )r8   ps     r?   centroidOGRGeometry.centroid8  s0     G,-$((AEE*rB   )r7   r2   r   rD   )F)P__name__
__module____qualname____firstlineno____doc__r)   destroy_geom
destructorr@   rG   rM   classmethodr0   staticmethodr/   r]   rS   rb   ri   rm   rq   ru   ry   r}   propertyr   r   setterr   r   r   r   r5   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   geojsonr   r   rE   r    r	  r  r  r  r  r   rx   r(  r-  r2  r6  r:  r>  rB  rF  rJ  rp   rl   rt   rf   r\  __static_attributes__ rB   r?   r   r   ?   se   &""J?#D$ 
 

 * * 
 
 L L ; ;
!
(
&
*E
 ' ' , ,
 * * - - . .         9 9 , , ' ' K K
 ' ' # # $ $W * *	+& 8X
&CA Iy)D0
 9 9 % % ) ) & & G+ + * * . ." 3 3  @(:
):6877688
= 0 0 4 44<85  rB   r   c                      ^  \ rS rSrU 4S jr\S 5       r\S 5       r\S 5       r	\S 5       r
\S 5       r\S 5       r\rS	rU =r$ )
rY  iB  c                    > SSK Jn  U R                  (       a  UR                  R	                  5       $ [
        TU ]  5       $ )Nr   )r   )django.contrib.gisr   r   rY  _create_emptysuperr   )r8   r   r7   s     r?   r   Point._geos_ptrC  s,    +-1ZZtzz'')PUW=N=PPrB   c                 T    [         R                  " [        S5      R                  5      $ )Npoint)r)   r*   r   r+   )rP   s    r?   ro  Point._create_emptyH  s    G 4 8 899rB   c                 D    [         R                  " U R                  S5      $ )z'Return the X coordinate for this Point.r   )r)   getxr2   r|   s    r?   xPoint.xL       yy1%%rB   c                 D    [         R                  " U R                  S5      $ )z'Return the Y coordinate for this Point.r   )r)   getyr2   r|   s    r?   yPoint.yQ  ry  rB   c                 h    U R                   (       a!  [        R                  " U R                  S5      $ g)z'Return the Z coordinate for this Point.r   N)r   r)   getzr2   r|   s    r?   zPoint.zV  s%     ::99TXXq)) rB   c                 h    U R                   (       a!  [        R                  " U R                  S5      $ g)z'Return the M coordinate for this Point.r   N)r   r)   getmr2   r|   s    r?   mPoint.m\  s'     99TXXq)) rB   c                    U R                   (       a?  U R                  (       a.  U R                  U R                  U R                  U R
                  4$ U R                   (       a#  U R                  U R                  U R                  4$ U R                  (       a#  U R                  U R                  U R
                  4$ U R                  U R                  4$ )zReturn the tuple of this point.)r   r   rw  r|  r  r  r|   s    r?   r   Point.tupleb  s     ::$**6646646646611::66466466))66466466))vvtvv~rB   rk  )r^  r_  r`  ra  r   re  ro  rg  rw  r|  r  r  r   coordsrj  __classcell__)r7   s   @r?   rY  rY  B  s    Q
 : : & & & & * *
 * *
   FrB   rY  c                   z    \ rS rSrS rS r\S 5       r\rS r	\S 5       r
\S 5       r\S 5       r\S	 5       rS
rg)
LineStringip  c           
      &   SUs=::  a  U R                   :  Gal  O  GOh[        5       [        5       [        5       [        5       4u  p#pE[        R                  " U R                  U[        U5      [        U5      [        U5      [        U5      5        U R                  (       a?  U R                  (       a.  UR                  UR                  UR                  UR                  4$ U R                  (       a#  UR                  UR                  UR                  4$ U R                  (       a#  UR                  UR                  UR                  4$ U R                  nUS:X  a  UR                  4$ US:X  a  UR                  UR                  4$ g[        SU-  5      e)z$Return the Point at the given index.r   r   r   z>Index out of range when accessing points of a line string: %s.N)r   r   r)   	get_pointr2   r   r   r   r   r   
IndexError)r8   indexrw  r|  r  r  r   s          r?   __getitem__LineString.__getitem__q  s    (((((!XZXZGJA!NN488UE!HeAha%PQ(Szzd..ww!''99zzww00ww00..Caxz!))  PSXX rB   c                     U R                   $ )z.Return the number of points in the LineString.r   r|   s    r?   __len__LineString.__len__  s    rB   c                 R   ^  [        U 4S j[        [        T 5      5       5       5      $ )z3Return the tuple representation of this LineString.c              3   .   >#    U  H
  nTU   v   M     g 7frD   rk  .0ir8   s     r?   	<genexpr>#LineString.tuple.<locals>.<genexpr>  s     7&6T!W&6s   )r   rangerK   r|   s   `r?   r   LineString.tuple  s     7eCI&6777rB   c                 v    [        [        U 5      5       Vs/ s H  o!" U R                  U5      PM     sn$ s  snf )zX
Internal routine that returns a sequence (list) corresponding with
the given function.
)r  rK   r2   )r8   r  r  s      r?   _listarrLineString._listarr  s2    
 ,1T+;<+;aTXXq!+;<<<s   6c                 @    U R                  [        R                  5      $ )z#Return the X coordinates in a list.)r  r)   rv  r|   s    r?   rw  LineString.x       }}TYY''rB   c                 @    U R                  [        R                  5      $ )z#Return the Y coordinates in a list.)r  r)   r{  r|   s    r?   r|  LineString.y  r  rB   c                 d    U R                   (       a  U R                  [        R                  5      $ g)z#Return the Z coordinates in a list.N)r   r  r)   r  r|   s    r?   r  LineString.z  s#     ::==++ rB   c                 d    U R                   (       a  U R                  [        R                  5      $ g)z#Return the M coordinates in a list.N)r   r  r)   r  r|   s    r?   r  LineString.m  s%     ==++ rB   rk  N)r^  r_  r`  ra  r  r  rg  r   r  r  rw  r|  r  r  rj  rk  rB   r?   r  r  p  s|    *  8 8 F= ( ( ( ( , ,
 , ,rB   r  c                       \ rS rSrSrg)
LinearRingi  rk  Nr^  r_  r`  ra  rj  rk  rB   r?   r  r        rB   r  c                   X    \ rS rSrS rS r\S 5       r\r\S 5       r	\	r
\S 5       rSrg)	Polygoni  c                     U R                   $ )z4Return the number of interior rings in this Polygon.r   r|   s    r?   r  Polygon.__len__      rB   c                     SUs=::  a  U R                   :  aL  O  OI[        [        R                  " [        R                  " U R
                  U5      5      U R                  5      $ [        SU-  5      e)z$Get the ring at the specified index.r   z9Index out of range when accessing rings of a polygon: %s.r   r   r)   r  get_geom_refr2   r   r  r8   r  s     r?   r  Polygon.__getitem__  sZ    '' 1 1$((E BCTXX  KeS rB   c                     U S   $ )z!Return the shell of this Polygon.r   rk  r|   s    r?   shellPolygon.shell  s     AwrB   c                 T   ^  [        U 4S j[        T R                  5       5       5      $ )z/Return a tuple of LinearRing coordinate tuples.c              3   B   >#    U  H  nTU   R                   v   M     g 7frD   r   r  s     r?   r   Polygon.tuple.<locals>.<genexpr>       C,BqT!W]],B   r   r  r   r|   s   `r?   r   Polygon.tuple       CE$//,BCCCrB   c                 T   ^  [        U 4S j[        T R                  5       5       5      $ )z,Return the number of Points in this Polygon.c              3   B   >#    U  H  nTU   R                   v   M     g 7frD   r   r  s     r?   r  &Polygon.point_count.<locals>.<genexpr>       G0F147&&0Fr  sumr  r   r|   s   `r?   r   Polygon.point_count       Gdoo0FGGGrB   rk  N)r^  r_  r`  ra  r  r  rg  r  exterior_ringr   r  r   rj  rk  rB   r?   r  r    sV    	   MD D FH HrB   r  c                   N    \ rS rSrSrS rS rS r\S 5       r	\S 5       r
\
rSrg	)
GeometryCollectioni  zThe Geometry Collection class.c                     SUs=::  a  U R                   :  aL  O  OI[        [        R                  " [        R                  " U R
                  U5      5      U R                  5      $ [        SU-  5      e)z(Get the Geometry at the specified index.r   z?Index out of range when accessing geometry in a collection: %s.r  r  s     r?   r  GeometryCollection.__getitem__  s]    '' 1 1$((E BCTXX  Q rB   c                     U R                   $ )z<Return the number of geometries in this Geometry Collection.r  r|   s    r?   r  GeometryCollection.__len__  r  rB   c                    [        U[        5      (       a{  [        XR                  5      (       a5  U H.  n[        R                  " U R
                  UR
                  5        M0     g[        R                  " U R
                  UR
                  5        g[        U[        5      (       a7  [        U5      n[        R                  " U R
                  UR
                  5        g[        S5      e)z-Add the geometry to this Geometry Collection.zMust add an OGRGeometry.N)r!   r   r7   r)   add_geomr2   r"   r   )r8   r   r=   tmps       r?   addGeometryCollection.add  s    dK(($//AMM$((AEE2  dhh1c""d#CMM$((CGG, :;;rB   c                 T   ^  [        U 4S j[        T R                  5       5       5      $ )z8Return the number of Points in this Geometry Collection.c              3   B   >#    U  H  nTU   R                   v   M     g 7frD   r   r  s     r?   r  1GeometryCollection.point_count.<locals>.<genexpr>   r  r  r  r|   s   `r?   r   GeometryCollection.point_count  r  rB   c                 T   ^  [        U 4S j[        T R                  5       5       5      $ )z:Return a tuple representation of this Geometry Collection.c              3   B   >#    U  H  nTU   R                   v   M     g 7frD   r  r  s     r?   r  +GeometryCollection.tuple.<locals>.<genexpr>  r  r  r  r|   s   `r?   r   GeometryCollection.tuple  r  rB   rk  N)r^  r_  r`  ra  rb  r  r  r  rg  r   r   r  rj  rk  rB   r?   r  r    sG    $
< H H
 D D FrB   r  c                       \ rS rSrSrg)
MultiPointi  rk  Nr  rk  rB   r?   r  r    r  rB   r  c                       \ rS rSrSrg)MultiLineStringi  rk  Nr  rk  rB   r?   r  r    r  rB   r  c                       \ rS rSrSrg)MultiPolygoni  rk  Nr  rk  rB   r?   r  r    r  rB   r  r   r   r               e   i  i  i  i  i  i  i  i  i  i  i  i  i  i  )1rb  r   r   binasciir   ctypesr   r   r   r   r   r	   django.contrib.gis.gdal.baser
    django.contrib.gis.gdal.enveloper   r   django.contrib.gis.gdal.errorr   r    django.contrib.gis.gdal.geomtyper   "django.contrib.gis.gdal.prototypesr   r)   r   r   django.contrib.gis.gdal.srsr   r   django.contrib.gis.geometryr   r   r   django.utils.deprecationr   django.utils.encodingr   r   rY  r  r  r  r  r  r  r  wkb25bitr3   rk  rB   r?   <module>r     s  'R    J J 1 B E 8 ; = H H H = -( F+K +\<, <,@	 	#Hk #HN, ,`	# 		( 		% 	
uz w z	
  |   	% 	* 	' 	* 	/ 	, 	
  	%!" 	*#$ 	'*/,
ejgjol0;rB   