ó
@ÒOc           @  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  s2   d j  g  | D] } d | d | d f ^ q ƒ 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    u   %f %fi   i    (   t   join(   t   selft   coordst   coord(    (    s1   ../Django//lib/python/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 pouplar
        W3C Geo specification.
        i   u   geo:latu   %fu   geo:lonu   georss:pointN(   t   addQuickElementR	   (   R   t   handlerR   t   w3c_geot   lont   lat(    (    s1   ../Django//lib/python/django/contrib/gis/feeds.pyt   add_georss_point   s
    c         C  sâ  | j  d d ƒ } | d k	 rÞt | t t f ƒ rd } t | d t t f ƒ r| t | ƒ d k rm | } 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 rY|  j | | j d | ƒqÞ| rn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(    (    s1   ../Django//lib/python/django/contrib/gis/feeds.pyt   add_georss_element!   s6    	  #(   t   __name__t
   __module__t   __doc__R	   t   FalseR   R   (    (    (    s1   ../Django//lib/python/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(    (    s1   ../Django//lib/python/django/contrib/gis/feeds.pyR%   R   s    
c         C  s-   t  t |  ƒ j | | ƒ |  j | | ƒ d  S(   N(   R$   R#   t   add_item_elementsR   (   R   R   R   (    (    s1   ../Django//lib/python/django/contrib/gis/feeds.pyR'   W   s    c         C  s-   t  t |  ƒ j | ƒ |  j | |  j ƒ d  S(   N(   R$   R#   t   add_root_elementsR   t   feed(   R   R   (    (    s1   ../Django//lib/python/django/contrib/gis/feeds.pyR(   [   s    (   R   R    R%   R'   R(   (    (    (    s1   ../Django//lib/python/django/contrib/gis/feeds.pyR#   Q   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&   (    (    s1   ../Django//lib/python/django/contrib/gis/feeds.pyR+   `   s    
c         C  s-   t  t |  ƒ j | | ƒ |  j | | ƒ d  S(   N(   R$   R*   R'   R   (   R   R   R   (    (    s1   ../Django//lib/python/django/contrib/gis/feeds.pyR'   e   s    c         C  s-   t  t |  ƒ j | ƒ |  j | |  j ƒ d  S(   N(   R$   R*   R(   R   R)   (   R   R   (    (    s1   ../Django//lib/python/django/contrib/gis/feeds.pyR(   i   s    (   R   R    R+   R'   R(   (    (    (    s1   ../Django//lib/python/django/contrib/gis/feeds.pyR*   _   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&   (    (    s1   ../Django//lib/python/django/contrib/gis/feeds.pyR%   n   s    
c         C  s3   t  t |  ƒ j | | ƒ |  j | | d t ƒd  S(   NR   (   R$   R,   R'   R   t   True(   R   R   R   (    (    s1   ../Django//lib/python/django/contrib/gis/feeds.pyR'   s   s    c         C  s3   t  t |  ƒ j | ƒ |  j | |  j d t ƒd  S(   NR   (   R$   R,   R(   R   R)   R-   (   R   R   (    (    s1   ../Django//lib/python/django/contrib/gis/feeds.pyR(   w   s    (   R   R    R%   R'   R(   (    (    (    s1   ../Django//lib/python/django/contrib/gis/feeds.pyR,   m   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   _Feed__get_dynamic_attr(   R   t   obj(    (    s1   ../Django//lib/python/django/contrib/gis/feeds.pyt   feed_extra_kwargs…   s    c         C  s   i |  j  d | ƒ d 6S(   Nu   item_geometryu   geometry(   R.   (   R   R   (    (    s1   ../Django//lib/python/django/contrib/gis/feeds.pyt   item_extra_kwargsˆ   s    (   R   R    R!   R#   t	   feed_typeR0   R1   (    (    (    s1   ../Django//lib/python/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,   (    (    (    s1   ../Django//lib/python/django/contrib/gis/feeds.pyt   <module>   s   K