ó
®â0_c           @  s±   d  d l  m Z d  d l m Z d  d l m Z m Z d e f d „  ƒ  YZ	 d e e	 f d „  ƒ  YZ
 d e e	 f d	 „  ƒ  YZ d
 e e	 f d „  ƒ  YZ d e f d „  ƒ  YZ d S(   iÿÿÿÿ(   t   unicode_literals(   t   Feed(   t	   Atom1Feedt   Rss201rev2Feedt   GeoFeedMixinc           B  s/   e  Z d  Z d „  Z e d „ Z e d „ Z RS(   u…   
    This mixin provides the necessary routines for SyndicationFeed subclasses
    to produce simple GeoRSS or W3C Geo elements.
    c         C  s   d j  d „  | Dƒ ƒ S(   uË   
        In GeoRSS coordinate pairs are ordered by lat/lon and separated by
        a single white space.  Given a tuple of coordinates, this will return
        a unicode GeoRSS representation.
        u    c         s  s'   |  ] } d  | d | d f Vq d S(   u   %f %fi   i    N(    (   t   .0t   coord(    (    s:   /tmp/pip-unpacked-wheel-BAJOf3/django/contrib/gis/feeds.pys	   <genexpr>   s    (   t   join(   t   selft   coords(    (    s:   /tmp/pip-unpacked-wheel-BAJOf3/django/contrib/gis/feeds.pyt   georss_coords   s    c         C  sa   | rA | d  \ } } | j  d d | ƒ | j  d d | ƒ n | j  d |  j | f ƒ ƒ d S(   u¾   
        Adds a GeoRSS point with the given coords using the given handler.
        Handles the differences between simple GeoRSS and the more popular
        W3C Geo specification.
        i   u   geo:latu   %fu   geo:lonu   georss:pointN(   t   addQuickElementR
   (   R   t   handlerR	   t   w3c_geot   lont   lat(    (    s:   /tmp/pip-unpacked-wheel-BAJOf3/django/contrib/gis/feeds.pyt   add_georss_point   s
    c         C  sß  | j  d ƒ } | d k	 rÛt | t t f ƒ rd } t | d t t f ƒ ry t | ƒ d k rj | } qÙ t d ƒ ‚ n` t | ƒ d k r¤ |  j | | d | ƒn5 t | ƒ d k rÍ | d  | d f } n t d ƒ ‚ | d k	 rØ| rú t d ƒ ‚ n  | j d	 |  j	 | ƒ ƒ qØqÛt
 | j ƒ j ƒ  } | d
 k rV|  j | | j d | ƒqÛ| rkt d ƒ ‚ n  | d k r–| j d |  j	 | j ƒ ƒ qÛ| d k rÅ| j d |  j	 | d j ƒ ƒ qÛt d | j ƒ ‚ n  d S(   uZ   
        This routine adds a GeoRSS XML element using the given item and handler.
        u   geometryi    i   u'   Only should be two sets of coordinates.R   i   u'   Only should be 2 or 4 numeric elements.u.   Cannot use simple GeoRSS box in W3C Geo feeds.u
   georss:boxu   pointu'   W3C Geo only supports Point geometries.u
   linestringu
   linearringu   georss:lineu   polygonu   georss:polygonu!   Geometry type "%s" not supported.N(   u
   linestringu
   linearring(   u   polygon(   t   gett   Nonet
   isinstancet   listt   tuplet   lent
   ValueErrorR   R   R
   t   strt	   geom_typet   lowerR	   (   R   R   t   itemR   t   geomt
   box_coordst   gtype(    (    s:   /tmp/pip-unpacked-wheel-BAJOf3/django/contrib/gis/feeds.pyt   add_georss_element"   s6    	#(   t   __name__t
   __module__t   __doc__R
   t   FalseR   R   (    (    (    s:   /tmp/pip-unpacked-wheel-BAJOf3/django/contrib/gis/feeds.pyR      s   	t
   GeoRSSFeedc           B  s#   e  Z d  „  Z d „  Z d „  Z RS(   c         C  s#   t  t |  ƒ j ƒ  } d | d <| S(   Nu   http://www.georss.org/georssu   xmlns:georss(   t   superR$   t   rss_attributes(   R   t   attrs(    (    s:   /tmp/pip-unpacked-wheel-BAJOf3/django/contrib/gis/feeds.pyR&   V   s    
c         C  s-   t  t |  ƒ j | | ƒ |  j | | ƒ d  S(   N(   R%   R$   t   add_item_elementsR   (   R   R   R   (    (    s:   /tmp/pip-unpacked-wheel-BAJOf3/django/contrib/gis/feeds.pyR(   [   s    c         C  s-   t  t |  ƒ j | ƒ |  j | |  j ƒ d  S(   N(   R%   R$   t   add_root_elementsR   t   feed(   R   R   (    (    s:   /tmp/pip-unpacked-wheel-BAJOf3/django/contrib/gis/feeds.pyR)   _   s    (   R    R!   R&   R(   R)   (    (    (    s:   /tmp/pip-unpacked-wheel-BAJOf3/django/contrib/gis/feeds.pyR$   U   s   		t   GeoAtom1Feedc           B  s#   e  Z d  „  Z d „  Z d „  Z RS(   c         C  s#   t  t |  ƒ j ƒ  } d | d <| S(   Nu   http://www.georss.org/georssu   xmlns:georss(   R%   R+   t   root_attributes(   R   R'   (    (    s:   /tmp/pip-unpacked-wheel-BAJOf3/django/contrib/gis/feeds.pyR,   e   s    
c         C  s-   t  t |  ƒ j | | ƒ |  j | | ƒ d  S(   N(   R%   R+   R(   R   (   R   R   R   (    (    s:   /tmp/pip-unpacked-wheel-BAJOf3/django/contrib/gis/feeds.pyR(   j   s    c         C  s-   t  t |  ƒ j | ƒ |  j | |  j ƒ d  S(   N(   R%   R+   R)   R   R*   (   R   R   (    (    s:   /tmp/pip-unpacked-wheel-BAJOf3/django/contrib/gis/feeds.pyR)   n   s    (   R    R!   R,   R(   R)   (    (    (    s:   /tmp/pip-unpacked-wheel-BAJOf3/django/contrib/gis/feeds.pyR+   d   s   		t
   W3CGeoFeedc           B  s#   e  Z d  „  Z d „  Z d „  Z RS(   c         C  s#   t  t |  ƒ j ƒ  } d | d <| S(   Nu(   http://www.w3.org/2003/01/geo/wgs84_pos#u	   xmlns:geo(   R%   R-   R&   (   R   R'   (    (    s:   /tmp/pip-unpacked-wheel-BAJOf3/django/contrib/gis/feeds.pyR&   t   s    
c         C  s3   t  t |  ƒ j | | ƒ |  j | | d t ƒd  S(   NR   (   R%   R-   R(   R   t   True(   R   R   R   (    (    s:   /tmp/pip-unpacked-wheel-BAJOf3/django/contrib/gis/feeds.pyR(   y   s    c         C  s3   t  t |  ƒ j | ƒ |  j | |  j d t ƒd  S(   NR   (   R%   R-   R)   R   R*   R.   (   R   R   (    (    s:   /tmp/pip-unpacked-wheel-BAJOf3/django/contrib/gis/feeds.pyR)   }   s    (   R    R!   R&   R(   R)   (    (    (    s:   /tmp/pip-unpacked-wheel-BAJOf3/django/contrib/gis/feeds.pyR-   s   s   		R   c           B  s&   e  Z d  Z e Z d „  Z d „  Z RS(   uÿ   
    This is a subclass of the `Feed` from `django.contrib.syndication`.
    This allows users to define a `geometry(obj)` and/or `item_geometry(item)`
    methods on their own subclasses so that geo-referenced information may
    placed in the feed.
    c         C  s   i |  j  d | ƒ d 6S(   Nu   geometry(   t   _get_dynamic_attr(   R   t   obj(    (    s:   /tmp/pip-unpacked-wheel-BAJOf3/django/contrib/gis/feeds.pyt   feed_extra_kwargsŒ   s    c         C  s   i |  j  d | ƒ d 6S(   Nu   item_geometryu   geometry(   R/   (   R   R   (    (    s:   /tmp/pip-unpacked-wheel-BAJOf3/django/contrib/gis/feeds.pyt   item_extra_kwargs   s    (   R    R!   R"   R$   t	   feed_typeR1   R2   (    (    (    s:   /tmp/pip-unpacked-wheel-BAJOf3/django/contrib/gis/feeds.pyR   ƒ   s   	N(   t
   __future__R    t    django.contrib.syndication.viewsR   t   BaseFeedt   django.utils.feedgeneratorR   R   t   objectR   R$   R+   R-   (    (    (    s:   /tmp/pip-unpacked-wheel-BAJOf3/django/contrib/gis/feeds.pyt   <module>   s   N