
 X/^                 @   sz  d  Z  d d l Z d d l m Z m Z d d l m Z m Z m Z m	 Z	 m
 Z
 m Z d d l m Z d d l m Z m Z d d l m Z m Z m Z d d l m Z d d	 l m Z m Z d d
 l m Z m Z d d l m  Z  m! Z! m" Z" d d l# m$ Z$ d d l% m& Z& Gd d   d e  Z' Gd d   d e'  Z( Gd d   d e'  Z) Gd d   d e)  Z* Gd d   d e'  Z+ Gd d   d e'  Z, Gd d   d e,  Z- Gd d   d e,  Z. Gd d   d e,  Z/ i e( d  6e) d! 6e+ d" 6e- d# 6e. d$ 6e/ d% 6e, d& 6e* d' 6e( d  e j0 6e) d! e j0 6e+ d" e j0 6e- d# e j0 6e. d$ e j0 6e/ d% e j0 6e, d& e j0 6Z1 d S)(a|  
 The OGRGeometry is a wrapper for using the OGR Geometry class
 (see http://www.gdal.org/classOGRGeometry.html).  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)a2b_hexb2a_hex)byrefc_char_pc_doublec_ubytec_void_p	string_at)GDALBase)EnvelopeOGREnvelope)GDALExceptionOGRIndexErrorSRSException)OGRGeomType)geomsrs)CoordTransformSpatialReference)	hex_regex
json_regex	wkt_regex)six)rangec               @   sv  e  Z d  Z d Z d d d  Z d d   Z d d   Z d	 d
   Z e 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 d d   Z d d    Z e e e  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 d- d.    Z e d/ d0    Z e d1 d2    Z d3 d4   Z d5 d6   Z  e e e   Z! d7 d8   Z" d9 d:   Z# e e" e#  Z$ e d; d<    Z% e d= d>    Z& e d? d@    Z' e dA dB    Z( e( Z) e dC dD    Z* e dE dF    Z+ e dG dH    Z, e dI dJ    Z- e dK dL    Z. dM dN   Z/ dO dP   Z0 dQ dR dS  Z1 dT dU   Z2 dV dW   Z3 dX dY   Z4 dZ d[   Z5 d\ d]   Z6 d^ d_   Z7 d` da   Z8 db dc   Z9 dd de   Z: d df dg  Z; e dh di    Z< e dj dk    Z= dl dm   Z> dn do   Z? dp dq   Z@ dr ds   ZA d S)tOGRGeometryz'Generally encapsulates an OGR geometry.Nc             C   ss  t  | t j  } | rQ t j |  rQ t j t | j   j     } d } n  | rt	 j |  } t
 j |  } | rH| j d  r t | j d   } n  | j d  j   d k rt j t | j d   j  } t j | t t | j d  j      qt j t t | j d  j     d t t     } q"| rft j | j    } q"t |  t j t |  j  } n t  | t j  rt j t |  d t t    t |   } nU t  | t  rt j | j  } n1 t  | |  j  r| } n t d t |    | sAt d t |    n  | |  _ | r\| |  _ n  t  |  j! j |  _" d S)	z>Initializes 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)#
isinstancer   string_typesr   match
memoryviewr   upperencoder   r   groupintcapiZcreate_geomr   numZ
import_wktr   r   Zfrom_wktr   Z	from_jsonfrom_wkbbyteslenZptr_typer   r   strptrr   GEO_CLASSES	geom_type	__class__)selfZ
geom_inputr   Zstr_instanceZwkt_mZjson_mg r2   P/home/ubuntu/projects/ifolica/build/django/django/contrib/gis/gdal/geometries.py__init__A   s>    !	!.<
0		zOGRGeometry.__init__c             C   s3   y t  j |  j  Wn t t f k
 r. Yn Xd S)zDeletes this Geometry.N)r&   Zdestroy_geomZ_ptrAttributeError	TypeError)r0   r2   r2   r3   __del__z   s    zOGRGeometry.__del__c             C   s4   |  j  } | r | j } n d  } t |  j  | f S)N)r   r   r)   wkb)r0   r   r2   r2   r3   __getstate__   s
    	zOGRGeometry.__getstate__c             C   s^   | \ } } t  j | d  t t    t |   } | sH t d   n  | |  _ | |  _ d  S)Nz.Invalid OGRGeometry loaded from pickled state.)r&   r(   r   r   r*   r   r,   r   )r0   stater8   r   r,   r2   r2   r3   __setstate__   s    '	zOGRGeometry.__setstate__c             C   s>   | \ } } } } t  d | | | | | | | | | | f
  S)z3Constructs a Polygon from a bounding box (4-tuple).z,POLYGON((%s %s, %s %s, %s %s, %s %s, %s %s)))r   )clsZbboxZx0Zy0Zx1y1r2   r2   r3   	from_bbox   s    zOGRGeometry.from_bboxc             C   s   |  j  |  S)z(Returns the union of the two geometries.)union)r0   otherr2   r2   r3   __or__   s    zOGRGeometry.__or__c             C   s   |  j  |  S)z8Returns the intersection of this Geometry and the other.)intersection)r0   r@   r2   r2   r3   __and__   s    zOGRGeometry.__and__c             C   s   |  j  |  S)z2Return the difference this Geometry and the other.)
difference)r0   r@   r2   r2   r3   __sub__   s    zOGRGeometry.__sub__c             C   s   |  j  |  S)z?Return the symmetric difference of this Geometry and the other.)sym_difference)r0   r@   r2   r2   r3   __xor__   s    zOGRGeometry.__xor__c             C   s$   t  | t  r |  j |  Sd Sd S)z$Is this Geometry equal to the other?FN)r   r   equals)r0   r@   r2   r2   r3   __eq__   s    zOGRGeometry.__eq__c             C   s   |  | k S)zTests for inequality.r2   )r0   r@   r2   r2   r3   __ne__   s    zOGRGeometry.__ne__c             C   s   |  j  S)z*WKT is used for the string representation.)r   )r0   r2   r2   r3   __str__   s    zOGRGeometry.__str__c             C   s   t  j |  j  S)z6Returns 0 for points, 1 for lines, and 2 for surfaces.)r&   Zget_dimsr,   )r0   r2   r2   r3   	dimension   s    zOGRGeometry.dimensionc             C   s   t  j |  j  S)z1Returns the coordinate dimension of the Geometry.)r&   Zget_coord_dimr,   )r0   r2   r2   r3   _get_coord_dim   s    zOGRGeometry._get_coord_dimc             C   s2   | d k r t  d   n  t j |  j |  d S)z/Sets the coordinate dimension of this Geometry.      z(Geometry dimension must be either 2 or 3N)rN   rO   )
ValueErrorr&   Zset_coord_dimr,   )r0   dimr2   r2   r3   _set_coord_dim   s    zOGRGeometry._set_coord_dimc             C   s   t  j |  j  S)z(The number of elements in this Geometry.)r&   Zget_geom_countr,   )r0   r2   r2   r3   
geom_count   s    zOGRGeometry.geom_countc             C   s   t  j |  j  S)z.Returns the number of Points in this Geometry.)r&   Zget_point_countr,   )r0   r2   r2   r3   point_count   s    zOGRGeometry.point_countc             C   s   |  j  S)z7Alias for `point_count` (same name method in GEOS API.))rT   )r0   r2   r2   r3   
num_points   s    zOGRGeometry.num_pointsc             C   s   |  j  S)zAlais for `point_count`.)rT   )r0   r2   r2   r3   
num_coords   s    zOGRGeometry.num_coordsc             C   s   t  t j |  j   S)z#Returns the Type for this Geometry.)r   r&   Zget_geom_typer,   )r0   r2   r2   r3   r.      s    zOGRGeometry.geom_typec             C   s   t  j |  j  S)z"Returns the Name of this Geometry.)r&   Zget_geom_namer,   )r0   r2   r2   r3   	geom_name   s    zOGRGeometry.geom_namec             C   s   t  j |  j  S)zIReturns the area for a LinearRing, Polygon, or MultiPolygon; 0 otherwise.)r&   Zget_arear,   )r0   r2   r2   r3   area   s    zOGRGeometry.areac             C   s"   t  t j |  j t t      S)z'Returns the envelope for this Geometry.)r   r&   Zget_enveloper,   r   r   )r0   r2   r2   r3   envelope   s    zOGRGeometry.envelopec             C   s
   |  j  j S)zDReturns the envelope as a 4-tuple, instead of as an Envelope object.)rY   tuple)r0   r2   r2   r3   extent   s    zOGRGeometry.extentc             C   sF   y) t  j |  j  } t t j |   SWn t k
 rA d SYn Xd S)z0Returns the Spatial Reference for this Geometry.N)r&   Zget_geom_srsr,   r   srs_apiZ	clone_srsr   )r0   srs_ptrr2   r2   r3   _get_srs   s
    zOGRGeometry._get_srsc             C   s   t  | t  r | j } n\ t  | t j t j  rL t |  } | j } n+ | d k ra d } n t d t |    t j	 |  j |  d S)z,Sets the SpatialReference for this geometry.Nz7Cannot assign spatial reference with object of type: %s)
r   r   r,   r   integer_typesr   r6   r   r&   Z
assign_srs)r0   r   r]   srr2   r2   r3   _set_srs  s    	zOGRGeometry._set_srsc             C   s   |  j  } | r | j Sd  S)N)r   r   )r0   r   r2   r2   r3   	_get_srid  s    	zOGRGeometry._get_sridc             C   s:   t  | t j  s | d  k r* | |  _ n t d   d  S)Nz!SRID must be set with an integer.)r   r   r_   r   r6   )r0   r   r2   r2   r3   	_set_srid"  s    zOGRGeometry._set_sridc             C   s#   d d l  m } | |  j |  j  S)z4Returns a GEOSGeometry object from this OGRGeometry.r   )GEOSGeometry)Zdjango.contrib.gis.geosrd   r8   r   )r0   rd   r2   r2   r3   geos+  s    zOGRGeometry.geosc             C   s   t  j |  j  S)z/Returns the GML representation of the Geometry.)r&   Zto_gmlr,   )r0   r2   r2   r3   gml1  s    zOGRGeometry.gmlc             C   s   t  |  j  j   S)z=Returns the hexadecimal representation of the WKB (a string).)r   r8   r"   )r0   r2   r2   r3   hex6  s    zOGRGeometry.hexc             C   s   t  j |  j  S)zF
        Returns the GeoJSON representation of this Geometry.
        )r&   Zto_jsonr,   )r0   r2   r2   r3   json;  s    zOGRGeometry.jsonc             C   s   t  j |  j d  S)z/Returns the KML representation of the Geometry.N)r&   Zto_kmlr,   )r0   r2   r2   r3   kmlC  s    zOGRGeometry.kmlc             C   s   t  j |  j  S)z#Returns the size of the WKB buffer.)r&   Zget_wkbsizer,   )r0   r2   r2   r3   wkb_sizeH  s    zOGRGeometry.wkb_sizec             C   sf   t  j d k r d } n d } |  j } t |   } t j |  j | t |   t j	 t
 | |   S)z/Returns the WKB representation of the Geometry.little   r   )sys	byteorderrj   r   r&   Zto_wkbr,   r   r   r!   r	   )r0   rn   szbufr2   r2   r3   r8   M  s    		zOGRGeometry.wkbc             C   s   t  j |  j t t     S)z/Returns the WKT representation of the Geometry.)r&   Zto_wktr,   r   r   )r0   r2   r2   r3   r   [  s    zOGRGeometry.wktc             C   s7   |  j  } | r, | j r, d | j |  j f S|  j Sd S)z0Returns the EWKT representation of the Geometry.z
SRID=%s;%sN)r   r   r   )r0   r   r2   r2   r3   ewkt`  s    	zOGRGeometry.ewktc             C   s   t  t j |  j  |  j  S)zClones this OGR Geometry.)r   r&   
clone_geomr,   r   )r0   r2   r2   r3   clonej  s    zOGRGeometry.clonec             C   s   t  j |  j  d S)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&   Zgeom_close_ringsr,   )r0   r2   r2   r3   close_ringsn  s    zOGRGeometry.close_ringsFc             C   s   | r# |  j    } | j |  | St | t  rK t j |  j | j  nr t | t  rs t j |  j | j  nJ t | t	 j
 t	 j  r t |  } t j |  j | j  n t d   d S)a  
        Transforms this geometry to a different spatial reference system.
        May take a CoordTransform object, a SpatialReference object, string
        WKT or PROJ.4, and/or an integer SRID.  By default nothing is returned
        and the geometry is transformed in-place.  However, if the `clone`
        keyword is set, then a transformed clone of this geometry will be
        returned.
        zUTransform only accepts CoordTransform, SpatialReference, string, and integer objects.N)rs   	transformr   r   r&   Zgeom_transformr,   r   Zgeom_transform_tor   r_   r   r6   )r0   Zcoord_transrs   Zkloner`   r2   r2   r3   ru   w  s    	zOGRGeometry.transformc             C   s1   t  | t  s t d   n  | |  j | j  S)zA 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   r,   )r0   funcr@   r2   r2   r3   	_topology  s    zOGRGeometry._topologyc             C   s   |  j  t j |  S)z8Returns True if this geometry intersects with the other.)rw   r&   Zogr_intersects)r0   r@   r2   r2   r3   
intersects  s    zOGRGeometry.intersectsc             C   s   |  j  t j |  S)z9Returns True if this geometry is equivalent to the other.)rw   r&   Z
ogr_equals)r0   r@   r2   r2   r3   rH     s    zOGRGeometry.equalsc             C   s   |  j  t j |  S)zCReturns True if this geometry and the other are spatially disjoint.)rw   r&   Zogr_disjoint)r0   r@   r2   r2   r3   disjoint  s    zOGRGeometry.disjointc             C   s   |  j  t j |  S)z0Returns True if this geometry touches the other.)rw   r&   Zogr_touches)r0   r@   r2   r2   r3   touches  s    zOGRGeometry.touchesc             C   s   |  j  t j |  S)z0Returns True if this geometry crosses the other.)rw   r&   Zogr_crosses)r0   r@   r2   r2   r3   crosses  s    zOGRGeometry.crossesc             C   s   |  j  t j |  S)z2Returns True if this geometry is within the other.)rw   r&   Z
ogr_within)r0   r@   r2   r2   r3   within  s    zOGRGeometry.withinc             C   s   |  j  t j |  S)z1Returns True if this geometry contains the other.)rw   r&   Zogr_contains)r0   r@   r2   r2   r3   contains  s    zOGRGeometry.containsc             C   s   |  j  t j |  S)z1Returns True if this geometry overlaps the other.)rw   r&   Zogr_overlaps)r0   r@   r2   r2   r3   overlaps  s    zOGRGeometry.overlapsc             C   sK   t  | t  r. t | |  j | j  |  j  St | |  j  |  j  Sd S)z?A helper routine for the OGR routines that generate geometries.N)r   r   r,   r   )r0   Zgen_funcr@   r2   r2   r3   _geomgen  s    zOGRGeometry._geomgenc             C   s   |  j  t j  S)z&Returns the boundary of this geometry.)r   r&   get_boundary)r0   r2   r2   r3   boundary  s    zOGRGeometry.boundaryc             C   s   |  j  t j  S)zl
        Returns the smallest convex Polygon that contains all the points in
        this Geometry.
        )r   r&   Zgeom_convex_hull)r0   r2   r2   r3   convex_hull  s    zOGRGeometry.convex_hullc             C   s   |  j  t j |  S)z
        Returns a new geometry consisting of the region which is the difference
        of this geometry and the other.
        )r   r&   Z	geom_diff)r0   r@   r2   r2   r3   rD     s    zOGRGeometry.differencec             C   s   |  j  t j |  S)zy
        Returns a new geometry consisting of the region of intersection of this
        geometry and the other.
        )r   r&   Zgeom_intersection)r0   r@   r2   r2   r3   rB     s    zOGRGeometry.intersectionc             C   s   |  j  t j |  S)zr
        Returns a new geometry which is the symmetric difference of this
        geometry and the other.
        )r   r&   Zgeom_sym_diff)r0   r@   r2   r2   r3   rF     s    zOGRGeometry.sym_differencec             C   s   |  j  t j |  S)z|
        Returns a new geometry consisting of the region which is the union of
        this geometry and the other.
        )r   r&   Z
geom_union)r0   r@   r2   r2   r3   r?     s    zOGRGeometry.union)B__name__
__module____qualname____doc__r4   r7   r9   r;   classmethodr>   rA   rC   rE   rG   rI   rJ   rK   propertyrL   rM   rR   	coord_dimrS   rT   rU   rV   r.   rW   rX   rY   r[   r^   ra   r   rb   rc   r   re   rf   rg   rh   Zgeojsonri   rj   r8   r   rq   rs   rt   ru   rw   rx   rH   ry   rz   r{   r|   r}   r~   r   r   r   rD   rB   rF   r?   r2   r2   r2   r3   r   >   sz   9	
	
r   c               @   s^   e  Z d  Z e d d    Z e d d    Z e d d    Z e d d    Z e Z d	 S)
Pointc             C   s   t  j |  j d  S)z(Returns the X coordinate for this Point.r   )r&   getxr,   )r0   r2   r2   r3   x  s    zPoint.xc             C   s   t  j |  j d  S)z(Returns the Y coordinate for this Point.r   )r&   getyr,   )r0   r2   r2   r3   y  s    zPoint.yc             C   s&   |  j  d k r" t j |  j d  Sd S)z(Returns the Z coordinate for this Point.rO   r   N)r   r&   getzr,   )r0   r2   r2   r3   z  s    zPoint.zc             C   sH   |  j  d k r |  j |  j f S|  j  d k rD |  j |  j |  j f Sd S)z Returns the tuple of this point.rN   rO   N)r   r   r   r   )r0   r2   r2   r3   rZ     s    zPoint.tupleN)	r   r   r   r   r   r   r   rZ   coordsr2   r2   r2   r3   r     s
   r   c               @   s   e  Z d  Z d d   Z d d   Z d d   Z e d d    Z e Z d	 d
   Z	 e d d    Z
 e d d    Z e d d    Z d S)
LineStringc             C   s   | d k r | |  j  k  r t   t   t   } } } t j |  j | t |  t |  t |   |  j } | d k r | j f S| d k r | j | j f S| d k r | j | j | j f Sn t d t	 |    d S)z%Returns the Point at the given index.r   rl   rN   rO   zindex out of range: %sN)
rT   r   r&   Z	get_pointr,   r   r   valuer   r+   )r0   indexr   r   r   rQ   r2   r2   r3   __getitem__  s    .	
zLineString.__getitem__c             c   s'   x  t  |  j  D] } |  | Vq Wd S)z+Iterates over each point in the LineString.N)r   rT   )r0   ir2   r2   r3   __iter__  s    zLineString.__iter__c             C   s   |  j  S)z:The length returns the number of points in the LineString.)rT   )r0   r2   r2   r3   __len__"  s    zLineString.__len__c                s)   t    f d d   t t     D  S)z4Returns the tuple representation of this LineString.c             3   s   |  ] }   | Vq d  S)Nr2   ).0r   )r0   r2   r3   	<genexpr>)  s    z#LineString.tuple.<locals>.<genexpr>)rZ   r   r*   )r0   r2   )r0   r3   rZ   &  s    zLineString.tuplec                s&      f d d   t  t    D S)zp
        Internal routine that returns a sequence (list) corresponding with
        the given function.
        c                s"   g  |  ] }    j  |   q Sr2   )r,   )r   r   )rv   r0   r2   r3   
<listcomp>1  s   	 z'LineString._listarr.<locals>.<listcomp>)r   r*   )r0   rv   r2   )rv   r0   r3   _listarr,  s    zLineString._listarrc             C   s   |  j  t j  S)z$Returns the X coordinates in a list.)r   r&   r   )r0   r2   r2   r3   r   3  s    zLineString.xc             C   s   |  j  t j  S)z$Returns the Y coordinates in a list.)r   r&   r   )r0   r2   r2   r3   r   8  s    zLineString.yc             C   s#   |  j  d k r |  j t j  Sd S)z$Returns the Z coordinates in a list.rO   N)r   r   r&   r   )r0   r2   r2   r3   r   =  s    zLineString.zN)r   r   r   r   r   r   r   rZ   r   r   r   r   r   r2   r2   r2   r3   r     s   r   c               @   s   e  Z d  Z d S)
LinearRingN)r   r   r   r2   r2   r2   r3   r   E  s   r   c               @   s   e  Z d  Z d d   Z d d   Z d d   Z e d d    Z e Z e d	 d
    Z	 e	 Z
 e d d    Z e d d    Z d S)Polygonc             C   s   |  j  S)z-The number of interior rings in this Polygon.)rS   )r0   r2   r2   r3   r   K  s    zPolygon.__len__c             c   s'   x  t  |  j  D] } |  | Vq Wd S)z*Iterates through each ring in the Polygon.N)r   rS   )r0   r   r2   r2   r3   r   O  s    zPolygon.__iter__c             C   sZ   | d k  s | |  j  k r. t d |   n( t t j t j |  j |   |  j  Sd S)z%Gets the ring at the specified index.r   zindex out of range: %sN)rS   r   r   r&   rr   get_geom_refr,   r   )r0   r   r2   r2   r3   r   T  s    zPolygon.__getitem__c             C   s   |  d S)z"Returns the shell of this Polygon.r   r2   )r0   r2   r2   r3   shell\  s    zPolygon.shellc                s&   t    f d d   t   j  D  S)z0Returns a tuple of LinearRing coordinate tuples.c             3   s   |  ] }   | j  Vq d  S)N)rZ   )r   r   )r0   r2   r3   r   e  s    z Polygon.tuple.<locals>.<genexpr>)rZ   r   rS   )r0   r2   )r0   r3   rZ   b  s    zPolygon.tuplec                s&   t    f d d   t   j  D  S)z%The number of Points in this Polygon.c             3   s   |  ] }   | j  Vq d  S)N)rT   )r   r   )r0   r2   r3   r   l  s    z&Polygon.point_count.<locals>.<genexpr>)sumr   rS   )r0   r2   )r0   r3   rT   h  s    zPolygon.point_countc             C   s,   t  t d   } t j |  j | j  | S)z/Returns the centroid (a Point) of this Polygon.r   )r   r   r&   Zget_centroidr,   )r0   pr2   r2   r3   centroidn  s    zPolygon.centroidN)r   r   r   r   r   r   r   r   Zexterior_ringrZ   r   rT   r   r2   r2   r2   r3   r   I  s   r   c               @   sp   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
 e
 Z d S)GeometryCollectionzThe Geometry Collection class.c             C   sZ   | d k  s | |  j  k r. t d |   n( t t j t j |  j |   |  j  Sd S)z)Gets the Geometry at the specified index.r   zindex out of range: %sN)rS   r   r   r&   rr   r   r,   r   )r0   r   r2   r2   r3   r   {  s    zGeometryCollection.__getitem__c             c   s'   x  t  |  j  D] } |  | Vq Wd S)zIterates over each Geometry.N)r   rS   )r0   r   r2   r2   r3   r     s    zGeometryCollection.__iter__c             C   s   |  j  S)z5The number of geometries in this Geometry Collection.)rS   )r0   r2   r2   r3   r     s    zGeometryCollection.__len__c             C   s   t  | t  rd t  | |  j  rK x= | D] } t j |  j | j  q( Wq t j |  j | j  nC t  | t j  r t |  } t j |  j | j  n t d   d S)z-Add the geometry to this Geometry Collection.zMust add an OGRGeometry.N)	r   r   r/   r&   Zadd_geomr,   r   r   r   )r0   r   r1   tmpr2   r2   r3   add  s    zGeometryCollection.addc                s&   t    f d d   t   j  D  S)z1The number of Points in this Geometry Collection.c             3   s   |  ] }   | j  Vq d  S)N)rT   )r   r   )r0   r2   r3   r     s    z1GeometryCollection.point_count.<locals>.<genexpr>)r   r   rS   )r0   r2   )r0   r3   rT     s    zGeometryCollection.point_countc                s&   t    f d d   t   j  D  S)z;Returns a tuple representation of this Geometry Collection.c             3   s   |  ] }   | j  Vq d  S)N)rZ   )r   r   )r0   r2   r3   r     s    z+GeometryCollection.tuple.<locals>.<genexpr>)rZ   r   rS   )r0   r2   )r0   r3   rZ     s    zGeometryCollection.tupleN)r   r   r   r   r   r   r   r   r   rT   rZ   r   r2   r2   r2   r3   r   x  s   r   c               @   s   e  Z d  Z d S)
MultiPointN)r   r   r   r2   r2   r2   r3   r     s   r   c               @   s   e  Z d  Z d S)MultiLineStringN)r   r   r   r2   r2   r2   r3   r     s   r   c               @   s   e  Z d  Z d S)MultiPolygonN)r   r   r   r2   r2   r2   r3   r     s   r   rl   rN   rO               e   )2r   rm   binasciir   r   ctypesr   r   r   r   r   r	   Zdjango.contrib.gis.gdal.baser
   Z django.contrib.gis.gdal.enveloper   r   Zdjango.contrib.gis.gdal.errorr   r   r   Z django.contrib.gis.gdal.geomtyper   Z"django.contrib.gis.gdal.prototypesr   r&   r   r\   Zdjango.contrib.gis.gdal.srsr   r   Z!django.contrib.gis.geometry.regexr   r   r   Zdjango.utilsr   Zdjango.utils.six.movesr   r   r   r   r   r   r   r   r   r   Zwkb25bitr-   r2   r2   r2   r3   <module>(   sJ   . 9//
