
    gk                         d dl mZ d dlmZmZ  G d d      Z G d dee      Z G d dee      Z G d	 d
ee      Z	 G d de      Zy)    )Feed)	Atom1FeedRss201rev2Feedc                   &    e Zd ZdZd ZddZddZy)GeoFeedMixinz
    This mixin provides the necessary routines for SyndicationFeed subclasses
    to produce simple GeoRSS or W3C Geo elements.
    c                 2    dj                  d |D              S )z
        In GeoRSS coordinate pairs are ordered by lat/lon and separated by
        a single white space. Given a tuple of coordinates, return a string
        GeoRSS representation.
         c              3   6   K   | ]  }d |d   |d   fz    yw)z%f %f   r   N ).0coords     p/var/www/python.vincentserveurtest.ovh/public_html/venv/lib/python3.12/site-packages/django/contrib/gis/feeds.py	<genexpr>z-GeoFeedMixin.georss_coords.<locals>.<genexpr>   s#     KF558U1X"66Fs   )join)selfcoordss     r   georss_coordszGeoFeedMixin.georss_coords   s     xxKFKKK    c                     |r3|dd \  }}|j                  dd|z         |j                  dd|z         y|j                  d| j                  |f             y)z
        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.
        N   zgeo:latz%fzgeo:lonzgeorss:point)addQuickElementr   )r   handlerr   w3c_geolonlats         r   add_georss_pointzGeoFeedMixin.add_georss_point   s[     bqzHC##Itcz:##Itcz:##ND4F4Fy4QRr   c                 V   |j                  d      }|t        |t        t        f      rd}t        |d   t        t        f      rt	        |      dk(  r|}nRt        d      t	        |      dk(  r| j                  |||       n$t	        |      dk(  r|dd |dd f}nt        d      |/|rt        d	      |j                  d
| j                  |             yyt        |j                        j                         }|dk(  r| j                  ||j                  |       y|rt        d      |dv r,|j                  d| j                  |j                               y|dv r/|j                  d| j                  |d   j                               yt        d|j                  z        y)z:Add a GeoRSS XML element using the given item and handler.geometryNr   r   z'Only should be two sets of coordinates.r      z'Only should be 2 or 4 numeric elements.z.Cannot use simple GeoRSS box in W3C Geo feeds.z
georss:boxpointz'W3C Geo only supports Point geometries.)
linestring
linearringzgeorss:line)polygonzgeorss:polygonz!Geometry type "%s" not supported.)get
isinstancelisttuplelen
ValueErrorr   r   r   str	geom_typelowerr   )r   r   itemr   geom
box_coordsgtypes          r   add_georss_elementzGeoFeedMixin.add_georss_element    s    xx
#$u. "
d1ge}54yA~%)
()RSS4yA~--gtW-MTa&*2AhQR%9
()RSS)(L  ++$d&8&8&D * DNN+113G#))'4;;)P()RSS  <<//)4+=+=dkk+J ,.//,d.@.@a.P )?$..P c r   N)F)__name__
__module____qualname____doc__r   r   r3   r   r   r   r   r      s    
LS7r   r   c                   2     e Zd Z fdZ fdZ fdZ xZS )
GeoRSSFeedc                 .    t         |          }d|d<   |S Nzhttp://www.georss.org/georsszxmlns:georsssuperrss_attributesr   attrs	__class__s     r   r>   zGeoRSSFeed.rss_attributes\   s    &( >nr   c                 J    t         |   ||       | j                  ||       y Nr=   add_item_elementsr3   r   r   r/   rA   s      r   rE   zGeoRSSFeed.add_item_elementsa   "    !'40.r   c                 \    t         |   |       | j                  || j                         y rC   r=   add_root_elementsr3   feedr   r   rA   s     r   rJ   zGeoRSSFeed.add_root_elementse   $    !'*3r   r4   r5   r6   r>   rE   rJ   __classcell__rA   s   @r   r9   r9   [       
/4 4r   r9   c                   2     e Zd Z fdZ fdZ fdZ xZS )GeoAtom1Feedc                 .    t         |          }d|d<   |S r;   )r=   root_attributesr?   s     r   rU   zGeoAtom1Feed.root_attributesk   s    ') >nr   c                 J    t         |   ||       | j                  ||       y rC   rD   rF   s      r   rE   zGeoAtom1Feed.add_item_elementsp   rG   r   c                 \    t         |   |       | j                  || j                         y rC   rI   rL   s     r   rJ   zGeoAtom1Feed.add_root_elementst   rM   r   )r4   r5   r6   rU   rE   rJ   rO   rP   s   @r   rS   rS   j   rQ   r   rS   c                   2     e Zd Z fdZ fdZ fdZ xZS )
W3CGeoFeedc                 .    t         |          }d|d<   |S )Nz(http://www.w3.org/2003/01/geo/wgs84_pos#z	xmlns:geor<   r?   s     r   r>   zW3CGeoFeed.rss_attributesz   s    &(Gkr   c                 N    t         |   ||       | j                  ||d       y NTr    rD   rF   s      r   rE   zW3CGeoFeed.add_item_elements   s'    !'40t<r   c                 `    t         |   |       | j                  || j                  d       y r\   rI   rL   s     r   rJ   zW3CGeoFeed.add_root_elements   s)    !'*DAr   rN   rP   s   @r   rY   rY   y   s    
=B Br   rY   c                        e Zd ZdZeZd Zd Zy)r   z
    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                 *    d| j                  d|      iS )Nr   _get_dynamic_attr)r   objs     r   feed_extra_kwargszFeed.feed_extra_kwargs   s    D22:sCDDr   c                 *    d| j                  d|      iS )Nr   item_geometryr`   )r   r/   s     r   item_extra_kwargszFeed.item_extra_kwargs   s    D22?DIJJr   N)r4   r5   r6   r7   r9   	feed_typerc   rf   r   r   r   r   r      s     IEKr   r   N)
 django.contrib.syndication.viewsr   BaseFeeddjango.utils.feedgeneratorr   r   r   r9   rS   rY   r   r   r   <module>rk      sR    = @R Rl4 449l 4B B K8 Kr   