
 Xib                 @   s  d  Z  d d l m Z d d l Z d d l Z d d l m Z m Z m Z d d l	 m
 Z
 d d l m Z m Z m Z d d l m Z d d l m Z d d	 l m Z d d
 l m Z d d l m Z d d l m Z d d l m Z d d l m Z m  Z  m! Z! m" Z" m# Z# d d l$ m% Z% d d l& m' Z' d d l( m) Z) d d l* m+ Z+ m, Z, e' Gd d   d e e   Z- Gd d   d e.  Z/ d S)zh
 This module contains the 'base' GEOSGeometry object -- all GEOS Geometries
 inherit from this object.
    )unicode_literalsN)	addressofbyrefc_double)gdal)	hex_regex
json_regex	wkt_regex)
prototypes)GEOSBase)GEOSCoordSeq)GEOSException)GEOM_PTR)	ListMixin)PreparedGeometry)ewkb_wwkb_rwkb_wwkt_rwkt_w)six)deconstructible)RemovedInDjango20Warning)force_bytes
force_textc               @   s  e  Z d  Z d Z d Z e Z d Z d d d  Z d d   Z	 d d	   Z
 d
 d   Z d d   Z d d   Z d d   Z d d   Z d d   Z d d   Z d d   Z d d   Z d d   Z d d   Z d  d!   Z d" d#   Z e d$ d%    Z e d& d'    Z e d( d)    Z e d* d+    Z e d, d-    Z e d. d/    Z e d0 d1    Z d2 d3   Z  e d4 d5    Z! e d6 d7    Z" e d8 d9    Z# e d: d;    Z$ e d< d=    Z% e d> d?    Z& d@ dA   Z' dB dC   Z( dD dE   Z) dF dG   Z* dH dI   Z+ dJ dK dL  Z, dM dN   Z- dO dP   Z. dQ dR   Z/ dS dT   Z0 dU dV   Z1 e dW dX    Z2 e2 j3 dY dX    Z2 dZ d[   Z4 d\ d]   Z5 e d^ d_    Z6 e d` da    Z7 e db dc    Z8 e dd de    Z9 e df dg    Z: e: Z; e dh di    Z< e dj dk    Z= e dl dm    Z> e dn do    Z? e dp dq    Z@ e dr ds    ZA e dt du    ZB d dv dw  ZC dx dy   ZD e dz d{    ZE d| d} d~  ZF e d d    ZG e d d    ZH d d   ZI e d d    ZJ d d   ZK e d d    ZL d d   ZM d d d d  ZN d d   ZO e d d    ZP d d   ZQ e d d    ZR d d   ZS e d d    ZT e d d    ZU d d   ZV d S)GEOSGeometryz6A class that, generally, encapsulates a GEOS geometry.NFc             C   s  t  | t  r t |  } n  t  | t j  rt j |  } | r | j d  rl t | j d   } n  t	   j
 t | j d    } qt j |  r t   j
 t |   } qt j |  rt j s t d   n  t   j
 t j |  j  } qt d   n t  | t  r)| } ng t  | t j  rPt   j
 |  } n@ t  | t  rtt j | j  } n t d t t |     | r| |  _ n t d   |  j |  d S)a  
        The base constructor for GEOS geometry objects, and may take the
        following inputs:

         * strings:
            - WKT
            - HEXEWKB (a PostGIS-specific canonical form)
            - GeoJSON (requires GDAL)
         * buffer:
            - WKB

        The `srid` keyword is used to specify the Source Reference Identifier
        (SRID) number for this Geometry.  If not set, the SRID will be None.
        sridwktz4Initializing geometry from JSON input requires GDAL.z>String or unicode input unrecognized as WKT EWKT, and HEXEWKB.z Improper geometry input type: %sz4Could not initialize GEOS Geometry with given input.N)
isinstancebytesr   r   string_typesr	   matchgroupintr   readr   r   r   r   r   HAS_GDAL
ValueErrorOGRGeometrywkbr   
memoryviewr   capi
geom_cloneptr	TypeErrorstrtyper   
_post_init)selfZ	geo_inputr   Zwkt_mg r3   N/home/ubuntu/projects/ifolica/build/django/django/contrib/gis/geos/geometry.py__init__&   s4    $	!	zGEOSGeometry.__init__c       
      C   s   | r! t  | t  r! | |  _ n  t j d k r d d l m } m } d d l m	 } d d l
 m } d d l m } m } m } m }	 i | d 6| d 6| d 6| d	 6| d
 6| d 6|	 d 6| d 6t _ n  t j |  j |  _ |  j   d S)z8Helper routine for performing post-initialization setup.N   )
LineString
LinearRing)Point)Polygon)GeometryCollection
MultiPointMultiLineStringMultiPolygonr                     )r   r#   r   r   _GEOS_CLASSESZ
linestringr7   r8   pointr9   Zpolygonr:   collectionsr;   r<   r=   r>   geom_typeid	__class___set_cs)
r1   r   r7   r8   r9   r:   r;   r<   r=   r>   r3   r3   r4   r0   ]   s$    "zGEOSGeometry._post_initc             C   s3   y t  j |  j  Wn t t f k
 r. Yn Xd S)zo
        Destroys this Geometry; in other words, frees the memory used by the
        GEOS C++ object.
        N)r*   destroy_geomZ_ptrAttributeErrorr-   )r1   r3   r3   r4   __del__{   s    zGEOSGeometry.__del__c             C   s
   |  j    S)z
        Returns a clone because the copy of a GEOSGeometry may contain an
        invalid pointer location if the original is garbage collected.
        )clone)r1   r3   r3   r4   __copy__   s    zGEOSGeometry.__copy__c             C   s
   |  j    S)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.
        )rN   )r1   Zmemodictr3   r3   r4   __deepcopy__   s    zGEOSGeometry.__deepcopy__c             C   s   |  j  S)z+EWKT is used for the string representation.)ewkt)r1   r3   r3   r4   __str__   s    zGEOSGeometry.__str__c             C   s    d |  j  t t |  j   f S)z8Short-hand representation because WKT may be very large.z<%s object at %s>)	geom_typehexr   r,   )r1   r3   r3   r4   __repr__   s    zGEOSGeometry.__repr__c             C   s   t  |  j  |  j f S)N)r   r(   r   )r1   r3   r3   r4   __getstate__   s    zGEOSGeometry.__getstate__c             C   sV   | \ } } t    j t j |   } | s< t d   n  | |  _ |  j |  d  S)Nz+Invalid Geometry loaded from pickled state.)r   r$   r   r)   r   r,   r0   )r1   stater(   r   r,   r3   r3   r4   __setstate__   s    	zGEOSGeometry.__setstate__c             C   sC   t  | t j  r |  j | k St  | t  r; |  j |  Sd Sd S)zx
        Equivalence testing, a Geometry may be compared with another Geometry
        or a WKT representation.
        FN)r   r   r    r   r   equals_exact)r1   otherr3   r3   r4   __eq__   s
    zGEOSGeometry.__eq__c             C   s   |  | k S)zThe not equals operator.r3   )r1   rZ   r3   r3   r4   __ne__   s    zGEOSGeometry.__ne__c             C   s   |  j  |  S)z1Returns the union of this Geometry and the other.)union)r1   rZ   r3   r3   r4   __or__   s    zGEOSGeometry.__or__c             C   s   |  j  |  S)z8Returns the intersection of this Geometry and the other.)intersection)r1   rZ   r3   r3   r4   __and__   s    zGEOSGeometry.__and__c             C   s   |  j  |  S)z2Return the difference this Geometry and the other.)
difference)r1   rZ   r3   r3   r4   __sub__   s    zGEOSGeometry.__sub__c             C   s   |  j  |  S)z?Return the symmetric difference of this Geometry and the other.)sym_difference)r1   rZ   r3   r3   r4   __xor__   s    zGEOSGeometry.__xor__c             C   s:   |  j  r- t t j |  j  |  j  |  _ n	 d |  _ d S)z/Sets the coordinate sequence for this Geometry.N)has_csr   r*   Zget_csr,   hasz_cs)r1   r3   r3   r4   rJ      s    	$zGEOSGeometry._set_csc             C   s   |  j  r |  j j   Sd S)z=Returns a clone of the coordinate sequence for this Geometry.N)re   rg   rN   )r1   r3   r3   r4   	coord_seq   s    	zGEOSGeometry.coord_seqc             C   s   t  j |  j  j   S)z?Returns a string representing the Geometry type, e.g. 'Polygon')r*   Z	geos_typer,   decode)r1   r3   r3   r4   rS      s    zGEOSGeometry.geom_typec             C   s   t  j |  j  S)z2Returns an integer representing the Geometry type.)r*   Zgeos_typeidr,   )r1   r3   r3   r4   rH      s    zGEOSGeometry.geom_typeidc             C   s   t  j |  j  S)z1Returns the number of geometries in the Geometry.)r*   Zget_num_geomsr,   )r1   r3   r3   r4   num_geom   s    zGEOSGeometry.num_geomc             C   s   t  j |  j  S)z2Returns the number of coordinates in the Geometry.)r*   Zget_num_coordsr,   )r1   r3   r3   r4   
num_coords   s    zGEOSGeometry.num_coordsc             C   s   |  j  S)z;Returns the number points, or coordinates, in the Geometry.)rk   )r1   r3   r3   r4   
num_points   s    zGEOSGeometry.num_pointsc             C   s   t  j |  j  S)zDReturns the dimension of this Geometry (0=point, 1=line, 2=surface).)r*   Zget_dimsr,   )r1   r3   r3   r4   dims   s    zGEOSGeometry.dimsc             C   s   t  j |  j  S)z:Converts this Geometry to normal form (or canonical form).)r*   Zgeos_normalizer,   )r1   r3   r3   r4   	normalize   s    zGEOSGeometry.normalizec             C   s   t  j |  j  S)zl
        Returns a boolean indicating whether the set of points in this Geometry
        are empty.
        )r*   Zgeos_isemptyr,   )r1   r3   r3   r4   empty  s    zGEOSGeometry.emptyc             C   s   t  j |  j  S)z0Returns whether the geometry has a 3D dimension.)r*   Z	geos_haszr,   )r1   r3   r3   r4   rf     s    zGEOSGeometry.haszc             C   s   t  j |  j  S)z.Returns whether or not the geometry is a ring.)r*   Zgeos_isringr,   )r1   r3   r3   r4   ring  s    zGEOSGeometry.ringc             C   s   t  j |  j  S)z)Returns false if the Geometry not simple.)r*   Zgeos_issimpler,   )r1   r3   r3   r4   simple  s    zGEOSGeometry.simplec             C   s   t  j |  j  S)z2This property tests the validity of this Geometry.)r*   Zgeos_isvalidr,   )r1   r3   r3   r4   valid  s    zGEOSGeometry.validc             C   s   t  j |  j  j   S)zL
        Returns a string containing the reason for any invalidity.
        )r*   Zgeos_isvalidreasonr,   ri   )r1   r3   r3   r4   valid_reason!  s    zGEOSGeometry.valid_reasonc             C   s   t  j |  j | j  S)z0Returns true if other.within(this) returns true.)r*   Zgeos_containsr,   )r1   rZ   r3   r3   r4   contains)  s    zGEOSGeometry.containsc             C   s   t  j |  j | j  S)z
        Return True if the DE-9IM Intersection Matrix for the two geometries is
        T*****FF*, *T****FF*, ***T**FF*, or ****T*FF*. If either geometry is
        empty, return False.
        )r*   Zgeos_coversr,   )r1   rZ   r3   r3   r4   covers-  s    zGEOSGeometry.coversc             C   s   t  j |  j | j  S)z
        Returns true if the DE-9IM intersection matrix for the two Geometries
        is T*T****** (for a point and a curve,a point and an area or a line and
        an area) 0******** (for two curves).
        )r*   Zgeos_crossesr,   )r1   rZ   r3   r3   r4   crosses5  s    zGEOSGeometry.crossesc             C   s   t  j |  j | j  S)zm
        Returns true if the DE-9IM intersection matrix for the two Geometries
        is FF*FF****.
        )r*   Zgeos_disjointr,   )r1   rZ   r3   r3   r4   disjoint=  s    zGEOSGeometry.disjointc             C   s   t  j |  j | j  S)zm
        Returns true if the DE-9IM intersection matrix for the two Geometries
        is T*F**FFF*.
        )r*   Zgeos_equalsr,   )r1   rZ   r3   r3   r4   equalsD  s    zGEOSGeometry.equalsr   c             C   s   t  j |  j | j t |   S)zl
        Returns true if the two Geometries are exactly equal, up to a
        specified tolerance.
        )r*   Zgeos_equalsexactr,   float)r1   rZ   	tolerancer3   r3   r4   rY   K  s    zGEOSGeometry.equals_exactc             C   s   t  j |  j | j  S)z'Returns true if disjoint returns false.)r*   Zgeos_intersectsr,   )r1   rZ   r3   r3   r4   
intersectsR  s    zGEOSGeometry.intersectsc             C   s   t  j |  j | j  S)z
        Returns true if the DE-9IM intersection matrix for the two Geometries
        is T*T***T** (for two points or two surfaces) 1*T***T** (for two curves).
        )r*   Zgeos_overlapsr,   )r1   rZ   r3   r3   r4   overlapsV  s    zGEOSGeometry.overlapsc             C   sS   t  | t j  s% t |  d k r4 t d   n  t j |  j | j t |   S)z
        Returns true if the elements in the DE-9IM intersection matrix for the
        two Geometries match the elements in pattern.
        	   z#invalid intersection matrix pattern)	r   r   r    lenr   r*   Zgeos_relatepatternr,   r   )r1   rZ   patternr3   r3   r4   relate_pattern]  s    %zGEOSGeometry.relate_patternc             C   s   t  j |  j | j  S)z
        Returns true if the DE-9IM intersection matrix for the two Geometries
        is FT*******, F**T***** or F***T****.
        )r*   Zgeos_touchesr,   )r1   rZ   r3   r3   r4   touchesf  s    zGEOSGeometry.touchesc             C   s   t  j |  j | j  S)zm
        Returns true if the DE-9IM intersection matrix for the two Geometries
        is T*F**F***.
        )r*   Zgeos_withinr,   )r1   rZ   r3   r3   r4   withinm  s    zGEOSGeometry.withinc             C   s*   t  j |  j  } | d k r" d S| Sd S)z?Gets the SRID for the geometry, returns None if no SRID is set.r   N)r*   Zgeos_get_sridr,   )r1   sr3   r3   r4   r   u  s    zGEOSGeometry.sridc             C   s)   t  j |  j | d k r d n |  d S)zSets the SRID for the geometry.Nr   )r*   Zgeos_set_sridr,   )r1   r   r3   r3   r4   r   ~  s    c             C   s   t  j d t d  |  j S)Nz<`get_srid()` is deprecated, use the `srid` property instead.r?   )warningswarnr   r   )r1   r3   r3   r4   get_srid  s    
zGEOSGeometry.get_sridc             C   s    t  j d t d  | |  _ d  S)Nz<`set_srid()` is deprecated, use the `srid` property instead.r?   )r   r   r   r   )r1   r   r3   r3   r4   set_srid  s    
zGEOSGeometry.set_sridc             C   s'   |  j  } | r  d | |  j f S|  j S)z@
        Returns the EWKT (SRID + WKT) of the Geometry.
        z
SRID=%s;%s)r   r   )r1   r   r3   r3   r4   rQ     s    	zGEOSGeometry.ewktc             C   s1   t  d |  j r d n d d d  j |   j   S)zBReturns the WKT (Well-Known Text) representation of this Geometry.dimr@   r?   ZtrimT)r   rf   writeri   )r1   r3   r3   r4   r     s    zGEOSGeometry.wktc             C   s%   t  d |  j r d n d  j |   S)z
        Returns the WKB of this Geometry in hexadecimal form.  Please note
        that the SRID is not included in this representation because it is not
        a part of the OGC specification (use the `hexewkb` property instead).
        r   r@   r?   )r   rf   	write_hex)r1   r3   r3   r4   rT     s    	zGEOSGeometry.hexc             C   s%   t  d |  j r d n d  j |   S)z
        Returns the EWKB of this Geometry in hexadecimal form.  This is an
        extension of the WKB specification that includes SRID value that are
        a part of this geometry.
        r   r@   r?   )r   rf   r   )r1   r3   r3   r4   hexewkb  s    zGEOSGeometry.hexewkbc             C   s$   t  j i |  j j d 6|  j d 6 S)zB
        Returns GeoJSON representation of this Geometry.
        r/   Zcoordinates)jsondumpsrI   __name__Zcoords)r1   r3   r3   r4   r     s    zGEOSGeometry.jsonc             C   s"   t  |  j r d n d  j |   S)z
        Returns the WKB (Well-Known Binary) representation of this Geometry
        as a Python buffer.  SRID and Z values are not included, use the
        `ewkb` property instead.
        r@   r?   )r   rf   r   )r1   r3   r3   r4   r(     s    zGEOSGeometry.wkbc             C   s"   t  |  j r d n d  j |   S)z
        Return the EWKB representation of this Geometry as a Python buffer.
        This is an extension of the WKB specification that includes any SRID
        value that are a part of this geometry.
        r@   r?   )r   rf   r   )r1   r3   r3   r4   ewkb  s    zGEOSGeometry.ewkbc             C   s    |  j  } d | |  j j | f S)z0Returns the KML representation of this Geometry.z<%s>%s</%s>)rS   rh   kml)r1   Zgtyper3   r3   r4   r     s    	zGEOSGeometry.kmlc             C   s
   t  |   S)z
        Returns a PreparedGeometry corresponding to this geometry -- it is
        optimized for the contains, intersects, and covers operations.
        )r   )r1   r3   r3   r4   prepared  s    zGEOSGeometry.preparedc             C   sf   t  j s t d   n  |  j rV y t  j |  j |  j  SWqV t  j k
 rR YqV Xn  t  j |  j  S)z+Returns the OGR Geometry for this Geometry.z+GDAL required to convert to an OGRGeometry.)r   r%   r   r   r'   r(   SRSException)r1   r3   r3   r4   ogr  s    		zGEOSGeometry.ogrc             C   sT   t  j s t d   n  |  j rP y t  j |  j  SWqP t  j k
 rL YqP Xn  d S)z;Returns the OSR SpatialReference for SRID of this Geometry.z2GDAL required to return a SpatialReference object.N)r   r%   r   r   ZSpatialReferencer   )r1   r3   r3   r4   srs  s    		zGEOSGeometry.srsc             C   s   |  j  S)zAlias for `srs` property.)r   )r1   r3   r3   r4   crs  s    zGEOSGeometry.crsc             C   s  |  j  } | | k r, | r% |  j   Sd Sn  t j sD t d   n  t | t j  r_ d } n' | d k sw | d k  r t d   n  t j |  j |  } | j	 |  t
   j | j  } | r t | d | j  S| rt j |  j  | |  _ |  j | j   n t d   d S)a  
        Requires GDAL. Transforms the geometry according to the given
        transformation object, which may be an integer SRID, and WKT or
        PROJ.4 string. By default, the geometry is transformed in-place and
        nothing is returned. However if the `clone` keyword is set, then this
        geometry will not be modified and a transformed clone will be returned
        instead.
        Nz6GDAL library is not available to transform() geometry.r   z5Calling transform() with no SRID set is not supportedr   zTransformed WKB was invalid.)r   rN   r   r%   r   r   ZCoordTransformr'   r(   	transformr   r$   r   r*   rK   r,   r0   )r1   ctrN   r   r2   r,   r3   r3   r4   r     s*    		
			zGEOSGeometry.transformc             C   s   t  | d |  j S)z9Helper routine to return Geometry from the given pointer.r   )r   r   )r1   Zgptrr3   r3   r4   	_topology'  s    zGEOSGeometry._topologyc             C   s   |  j  t j |  j   S)z:Returns the boundary as a newly allocated Geometry object.)r   r*   Zgeos_boundaryr,   )r1   r3   r3   r4   boundary+  s    zGEOSGeometry.boundary   c             C   s   |  j  t j |  j | |   S)a  
        Returns a geometry that represents all points whose distance from this
        Geometry is less than or equal to distance. Calculations are in the
        Spatial Reference System of this Geometry. The optional third parameter sets
        the number of segment used to approximate a quarter circle (defaults to 8).
        (Text from PostGIS documentation at ch. 6.1.3)
        )r   r*   Zgeos_bufferr,   )r1   widthZquadsegsr3   r3   r4   buffer0  s    zGEOSGeometry.bufferc             C   s   |  j  t j |  j   S)z
        The centroid is equal to the centroid of the set of component Geometries
        of highest dimension (since the lower-dimension geometries contribute zero
        "weight" to the centroid).
        )r   r*   Zgeos_centroidr,   )r1   r3   r3   r4   centroid:  s    zGEOSGeometry.centroidc             C   s   |  j  t j |  j   S)zk
        Returns the smallest convex Polygon that contains all the points
        in the Geometry.
        )r   r*   Zgeos_convexhullr,   )r1   r3   r3   r4   convex_hullC  s    zGEOSGeometry.convex_hullc             C   s   |  j  t j |  j | j   S)zw
        Returns a Geometry representing the points making up this Geometry
        that do not make up other.
        )r   r*   Zgeos_differencer,   )r1   rZ   r3   r3   r4   ra   K  s    zGEOSGeometry.differencec             C   s   |  j  t j |  j   S)z2Return the envelope for this geometry (a polygon).)r   r*   Zgeos_enveloper,   )r1   r3   r3   r4   envelopeR  s    zGEOSGeometry.envelopec             C   s   |  j  t j |  j | j   S)zMReturns a Geometry representing the points shared by this Geometry and other.)r   r*   Zgeos_intersectionr,   )r1   rZ   r3   r3   r4   r_   W  s    zGEOSGeometry.intersectionc             C   s   |  j  t j |  j   S)z,Computes an interior point of this Geometry.)r   r*   Zgeos_pointonsurfacer,   )r1   r3   r3   r4   point_on_surface[  s    zGEOSGeometry.point_on_surfacec             C   s   t  j |  j | j  j   S)zGReturns the DE-9IM intersection matrix for this Geometry and the other.)r*   Zgeos_relater,   ri   )r1   rZ   r3   r3   r4   relate`  s    zGEOSGeometry.relateg        c             C   sB   | r" |  j  t j |  j |   S|  j  t j |  j |   Sd S)a4  
        Returns the Geometry, simplified using the Douglas-Peucker algorithm
        to the specified tolerance (higher tolerance => less points).  If no
        tolerance provided, defaults to 0.

        By default, this function does not preserve topology - e.g. polygons can
        be split, collapse to lines or disappear holes can be created or
        disappear, and lines can cross. By specifying preserve_topology=True,
        the result will have the same dimension and number of components as the
        input. This is significantly slower.
        N)r   r*   Zgeos_preservesimplifyr,   Zgeos_simplify)r1   rz   Zpreserve_topologyr3   r3   r4   simplifyd  s    zGEOSGeometry.simplifyc             C   s   |  j  t j |  j | j   S)z
        Returns a set combining the points in this Geometry not in other,
        and the points in other not in this Geometry.
        )r   r*   Zgeos_symdifferencer,   )r1   rZ   r3   r3   r4   rc   u  s    zGEOSGeometry.sym_differencec             C   s   |  j  t j |  j   S)z6Return the union of all the elements of this geometry.)r   r*   Zgeos_unary_unionr,   )r1   r3   r3   r4   unary_union|  s    zGEOSGeometry.unary_unionc             C   s   |  j  t j |  j | j   S)zJReturns a Geometry representing all the points in this Geometry and other.)r   r*   Z
geos_unionr,   )r1   rZ   r3   r3   r4   r]     s    zGEOSGeometry.unionc             C   s   t  j |  j t t     S)z!Returns the area of the Geometry.)r*   Z	geos_arear,   r   r   )r1   r3   r3   r4   area  s    zGEOSGeometry.areac             C   s@   t  | t  s t d   n  t j |  j | j t t     S)z
        Returns the distance between the closest points on this Geometry
        and the other. Units will be in those of the coordinate system of
        the Geometry.
        z/distance() works only on other GEOS Geometries.)r   r   r-   r*   Zgeos_distancer,   r   r   )r1   rZ   r3   r3   r4   distance  s    zGEOSGeometry.distancec             C   s   d d l  m } |  j } t | |  rG | j \ } } | | } } n( | d d \ } } | d d \ } } | | | | f S)zs
        Returns the extent of this geometry as a 4-tuple, consisting of
        (xmin, ymin, xmax, ymax).
        r6   )r9   r   r?   )rF   r9   r   r   tuple)r1   r9   envZxminZyminZxmaxZymaxr3   r3   r4   extent  s    	zGEOSGeometry.extentc             C   s   t  j |  j t t     S)zu
        Returns the length of this Geometry (e.g., 0 for point, or the
        circumference of a Polygon).
        )r*   Zgeos_lengthr,   r   r   )r1   r3   r3   r4   length  s    zGEOSGeometry.lengthc             C   s   t  t j |  j  d |  j S)zClones this Geometry.r   )r   r*   r+   r,   r   )r1   r3   r3   r4   rN     s    zGEOSGeometry.clone)Wr   
__module____qualname____doc__rE   r   Zptr_typere   r5   r0   rM   rO   rP   rR   rU   rV   rX   r[   r\   r^   r`   rb   rd   rJ   propertyrh   rS   rH   rj   rk   rl   rm   rn   ro   rf   rp   rq   rr   rs   rt   ru   rv   rw   rx   rY   r{   r|   r   r   r   r   setterr   r   rQ   r   rT   r   r   Zgeojsonr(   r   r   r   r   r   r   r   r   r   r   r   r   ra   r   r_   r   r   r   rc   r   r]   r   r   r   r   rN   r3   r3   r3   r4   r      s   7

						.
	
r   c               @   sj   e  Z d  Z d Z d d   Z d d   Z d d   Z d d	   Z e d
 d    Z	 e d d    Z
 d S)LinearGeometryMixinz2
    Used for LineString and MultiLineString.
    c             C   s   |  j  t j |  j |   S)N)r   r*   Zgeos_interpolater,   )r1   r   r3   r3   r4   interpolate  s    zLinearGeometryMixin.interpolatec             C   s   |  j  t j |  j |   S)N)r   r*   Zgeos_interpolate_normalizedr,   )r1   r   r3   r3   r4   interpolate_normalized  s    z*LinearGeometryMixin.interpolate_normalizedc             C   sD   d d l  m } t | |  s. t d   n  t j |  j | j  S)Nr6   )r9   z%locate_point argument must be a Point)rF   r9   r   r-   r*   Zgeos_projectr,   )r1   rF   r9   r3   r3   r4   project  s    zLinearGeometryMixin.projectc             C   sD   d d l  m } t | |  s. t d   n  t j |  j | j  S)Nr6   )r9   z%locate_point argument must be a Point)rF   r9   r   r-   r*   Zgeos_project_normalizedr,   )r1   rF   r9   r3   r3   r4   project_normalized  s    z&LinearGeometryMixin.project_normalizedc             C   s   |  j  t j |  j   S)z9
        Return the line merge of this Geometry.
        )r   r*   Zgeos_linemerger,   )r1   r3   r3   r4   merged  s    zLinearGeometryMixin.mergedc             C   s   t  j |  j  S)z@
        Return whether or not this Geometry is closed.
        )r*   Zgeos_isclosedr,   )r1   r3   r3   r4   closed  s    zLinearGeometryMixin.closedN)r   r   r   r   r   r   r   r   r   r   r   r3   r3   r3   r4   r     s   r   )0r   
__future__r   r   r   ctypesr   r   r   Zdjango.contrib.gisr   Z!django.contrib.gis.geometry.regexr   r   r	   Zdjango.contrib.gis.geosr
   r*   Zdjango.contrib.gis.geos.baser   Z django.contrib.gis.geos.coordseqr   Zdjango.contrib.gis.geos.errorr   Zdjango.contrib.gis.geos.libgeosr   Z$django.contrib.gis.geos.mutable_listr   Z django.contrib.gis.geos.preparedr   Z%django.contrib.gis.geos.prototypes.ior   r   r   r   r   Zdjango.utilsr   Zdjango.utils.deconstructr   Zdjango.utils.deprecationr   Zdjango.utils.encodingr   r   r   objectr   r3   r3   r3   r4   <module>   s.   (  