ó
®â0_c           @   sY  d  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 d d l m Z m Z d d l m Z m Z d d l 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 e f d „  ƒ  YZ d e f d „  ƒ  YZ d e e f d „  ƒ  YZ d e f d „  ƒ  YZ  e e e e e e e  f e _! d S(   sy   
 This module houses the Geometry Collection objects:
 GeometryCollection, MultiPoint, MultiLineString, and MultiPolygon
iÿÿÿÿN(   t   byreft   c_intt   c_uint(   t
   prototypes(   t   GEOSException(   t   GEOSGeometryt   LinearGeometryMixin(   t   geos_version_infot   get_pointer_arr(   t
   LinearRingt
   LineString(   t   Point(   t   Polygon(   t   RemovedInDjango20Warning(   t   ranget   GeometryCollectionc           B   s˜   e  Z d  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z	 e
 j Z e
 j Z e d „  ƒ Z e Z e d	 „  ƒ Z e d
 „  ƒ Z e Z RS(   i   c         O   s   t  | ƒ d k rA t | d t t f ƒ r8 | d } qG | } n | } |  j | ƒ |  j t  | ƒ t | ƒ ƒ } t t |  ƒ j	 | |  d S(   sF   Initializes a Geometry Collection from a sequence of Geometry objects.i   i    N(
   t   lent
   isinstancet   tuplet   listt   _check_allowedt   _create_collectiont   itert   superR   t   __init__(   t   selft   argst   kwargst
   init_geomst
   collection(    (    sE   /tmp/pip-unpacked-wheel-BAJOf3/django/contrib/gis/geos/collections.pyR      s    	c         c   s*   x# t  t |  ƒ ƒ D] } |  | Vq Wd S(   s.   Iterates over each Geometry in the Collection.N(   R   R   (   R   t   i(    (    sE   /tmp/pip-unpacked-wheel-BAJOf3/django/contrib/gis/geos/collections.pyt   __iter__-   s    c         C   s   |  j  S(   s4   Returns the number of geometries in this Collection.(   t   num_geom(   R   (    (    sE   /tmp/pip-unpacked-wheel-BAJOf3/django/contrib/gis/geos/collections.pyt   __len__2   s    c         C   sp   t  | ƒ } x9 t | ƒ D]+ \ } } t j t | d | ƒ ƒ | | <q Wt j t |  j ƒ t | ƒ t	 | ƒ ƒ S(   Nt   ptr(
   R   t	   enumeratet   capit
   geom_clonet   getattrt   create_collectionR   t   _typeidR    R   (   R   t   lengtht   itemst   geomsR   t   g(    (    sE   /tmp/pip-unpacked-wheel-BAJOf3/django/contrib/gis/geos/collections.pyR   7   s    #c         C   s   t  j |  j | ƒ S(   N(   R$   t	   get_geomnR"   (   R   t   index(    (    sE   /tmp/pip-unpacked-wheel-BAJOf3/django/contrib/gis/geos/collections.pyt   _get_single_internalA   s    c         C   s%   t  t j |  j | ƒ ƒ d |  j ƒS(   sG   Returns the Geometry from this Collection at the given index (0-based).t   srid(   R   R$   R%   R/   R0   (   R   R.   (    (    sE   /tmp/pip-unpacked-wheel-BAJOf3/django/contrib/gis/geos/collections.pyt   _get_single_externalD   s    c         C   sJ   |  j  } |  j } |  j | | ƒ |  _  | r9 | |  _ n  t j | ƒ d S(   sJ   Create a new collection, and destroy the contents of the previous pointer.N(   R"   R0   R   R$   t   destroy_geom(   R   R)   R*   t   prev_ptrR0   (    (    sE   /tmp/pip-unpacked-wheel-BAJOf3/django/contrib/gis/geos/collections.pyt	   _set_listI   s    		c         C   sm   |  j  j d k r] t j i |  j  j d 6g  |  D]# } i | j  j d 6| j d 6^ q/ d 6ƒ St t |  ƒ j S(   NR   t   typet   coordinatest
   geometries(   t	   __class__t   __name__t   jsont   dumpst   coordsR   R   (   R   t   geom(    (    sE   /tmp/pip-unpacked-wheel-BAJOf3/django/contrib/gis/geos/collections.pyR:   U   s    	2c         C   s   d d j  d „  |  Dƒ ƒ S(   s-   Returns the KML for this Geometry Collection.s!   <MultiGeometry>%s</MultiGeometry>t    c         s   s   |  ] } | j  Vq d  S(   N(   t   kml(   t   .0R,   (    (    sE   /tmp/pip-unpacked-wheel-BAJOf3/django/contrib/gis/geos/collections.pys	   <genexpr>e   s    (   t   join(   R   (    (    sE   /tmp/pip-unpacked-wheel-BAJOf3/django/contrib/gis/geos/collections.pyR?   b   s    c         C   s   t  d „  |  Dƒ ƒ S(   sB   Returns a tuple of all the coordinates in this Geometry Collectionc         s   s   |  ] } | j  Vq d  S(   N(   R   (   R@   R,   (    (    sE   /tmp/pip-unpacked-wheel-BAJOf3/django/contrib/gis/geos/collections.pys	   <genexpr>j   s    (   R   (   R   (    (    sE   /tmp/pip-unpacked-wheel-BAJOf3/django/contrib/gis/geos/collections.pyR   g   s    (   R9   t
   __module__R(   R   R   R!   R   R/   R1   R4   R   t   _set_single_rebuildt   _set_singlet   _assign_extended_slice_rebuildt   _assign_extended_slicet   propertyR:   t   geojsonR?   R   R<   (    (    (    sE   /tmp/pip-unpacked-wheel-BAJOf3/django/contrib/gis/geos/collections.pyR      s   				
						t
   MultiPointc           B   s   e  Z e Z d  Z RS(   i   (   R9   RB   R   t   _allowedR(   (    (    (    sE   /tmp/pip-unpacked-wheel-BAJOf3/django/contrib/gis/geos/collections.pyRI   o   s   t   MultiLineStringc           B   s)   e  Z e e f Z d  Z e d „  ƒ Z RS(   i   c         C   s2   t  ƒ  d d k  r" t d ƒ ‚ n  t t |  ƒ j S(   Nt   versions   3.5s.   MultiLineString.closed requires GEOS >= 3.5.0.(   R   R   R   RK   t   closed(   R   (    (    sE   /tmp/pip-unpacked-wheel-BAJOf3/django/contrib/gis/geos/collections.pyRM   x   s    (   R9   RB   R
   R	   RJ   R(   RG   RM   (    (    (    sE   /tmp/pip-unpacked-wheel-BAJOf3/django/contrib/gis/geos/collections.pyRK   t   s   t   MultiPolygonc           B   s#   e  Z e Z d  Z e d „  ƒ Z RS(   i   c         C   s/   t  j d t d ƒ t t j |  j ƒ |  j ƒ S(   s.   Returns a cascaded union of this MultiPolygon.sG   `cascaded_union` is deprecated, use the `unary_union` property instead.i   (   t   warningst   warnR   R   R$   t   geos_cascaded_unionR"   R0   (   R   (    (    sE   /tmp/pip-unpacked-wheel-BAJOf3/django/contrib/gis/geos/collections.pyt   cascaded_unionƒ   s    
(   R9   RB   R   RJ   R(   RG   RR   (    (    (    sE   /tmp/pip-unpacked-wheel-BAJOf3/django/contrib/gis/geos/collections.pyRN      s   ("   t   __doc__R:   RO   t   ctypesR    R   R   t   django.contrib.gis.geosR   R$   t   django.contrib.gis.geos.errorR   t    django.contrib.gis.geos.geometryR   R   t   django.contrib.gis.geos.libgeosR   R   t"   django.contrib.gis.geos.linestringR	   R
   t   django.contrib.gis.geos.pointR   t   django.contrib.gis.geos.polygonR   t   django.utils.deprecationR   t   django.utils.six.movesR   R   RI   RK   RN   RJ   (    (    (    sE   /tmp/pip-unpacked-wheel-BAJOf3/django/contrib/gis/geos/collections.pyt   <module>   s"   [