
    Dvgk                         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dS )    )Feed)	Atom1FeedRss201rev2Feedc                   (    e Zd ZdZd ZddZddZdS )GeoFeedMixinz
    This mixin provides the necessary routines for SyndicationFeed subclasses
    to produce simple GeoRSS or W3C Geo elements.
    c                 @    d                     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   <   K   | ]}d |d         |d         fz  V  dS )z%f %f   r   N ).0coords     U/var/www/pixelcanvas.ch/venv/lib/python3.11/site-packages/django/contrib/gis/feeds.py	<genexpr>z-GeoFeedMixin.georss_coords.<locals>.<genexpr>   s4      KK558U1X"66KKKKKK    )join)selfcoordss     r   georss_coordszGeoFeedMixin.georss_coords   s%     xxKKFKKKKKKr   Fc                     |rA|dd         \  }}|                     dd|z             |                     dd|z             dS |                     d|                     |f                     dS )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      	SbqbzHC##Itcz:::##Itcz:::::##ND4F4Fy4Q4QRRRRRr   c                    |                     d          }|t          |t          t          f          rd}t          |d         t          t          f          r%t	          |          dk    r|}nrt          d          t	          |          dk    r|                     |||           n7t	          |          dk    r|dd         |dd         f}nt          d          |<|rt          d	          |                    d
|                     |                     dS dS t          |j
                                                  }|dk    r|                     ||j        |           dS |rt          d          |dv r0|                    d|                     |j                             dS |dv r6|                    d|                     |d         j                             dS t          d|j
        z            dS )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    sX    xx
##$u.. 2 "
d1ge}55 T4yyA~~%)

()RSSS4yyA~~--gtW-MMMMTa&*2A2hQRR%9

()RSSS) (L   ++$d&8&8&D&D     *) DN++1133G##))'4;)PPPPP T()RSSS  <<<//)4+=+=dk+J+J     ,..//,d.@.@a.P.P     )?$.P  c r   N)F)__name__
__module____qualname____doc__r   r   r3   r   r   r   r   r      s\         
L L LS S S S7 7 7 7 7 7r   r   c                   2     e Zd Z fdZ fdZ fdZ xZS )
GeoRSSFeedc                 R    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                 x    t                                          ||           |                     ||           d S Nr=   add_item_elementsr3   r   r   r/   rA   s      r   rE   zGeoRSSFeed.add_item_elementsa   9    !!'4000.....r   c                     t                                          |           |                     || j                   d S rC   r=   add_root_elementsr3   feedr   r   rA   s     r   rJ   zGeoRSSFeed.add_root_elementse   9    !!'***33333r   r4   r5   r6   r>   rE   rJ   __classcell__rA   s   @r   r9   r9   [   j            
/ / / / /4 4 4 4 4 4 4 4 4r   r9   c                   2     e Zd Z fdZ fdZ fdZ xZS )GeoAtom1Feedc                 R    t                                                      }d|d<   |S r;   )r=   root_attributesr?   s     r   rU   zGeoAtom1Feed.root_attributesk   s'    '')) >nr   c                 x    t                                          ||           |                     ||           d S rC   rD   rF   s      r   rE   zGeoAtom1Feed.add_item_elementsp   rG   r   c                     t                                          |           |                     || j                   d S 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                 R    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                 |    t                                          ||           |                     ||d           d S NTr    rD   rF   s      r   rE   zW3CGeoFeed.add_item_elements   s>    !!'4000t<<<<<r   c                     t                                          |           |                     || j        d           d S r\   rI   rL   s     r   rJ   zW3CGeoFeed.add_root_elements   s>    !!'***DAAAAAr   rN   rP   s   @r   rY   rY   y   ss            
= = = = =B B B B B B B B Br   rY   c                   "    e Zd ZdZeZd Zd ZdS )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                 2    d|                      d|          iS )Nr   _get_dynamic_attr)r   objs     r   feed_extra_kwargszFeed.feed_extra_kwargs   s    D22:sCCDDr   c                 2    d|                      d|          iS )Nr   item_geometryr`   )r   r/   s     r   item_extra_kwargszFeed.item_extra_kwargs   s    D22?DIIJJr   N)r4   r5   r6   r7   r9   	feed_typerc   rf   r   r   r   r   r      sK          IE E EK K K K Kr   r   N)
 django.contrib.syndication.viewsr   BaseFeeddjango.utils.feedgeneratorr   r   r   r9   rS   rY   r   r   r   <module>rk      s*   = = = = = = @ @ @ @ @ @ @ @R R R R R R R Rl4 4 4 4 4 4 4 44 4 4 4 49l 4 4 4B B B B B B B B K K K K K8 K K K K Kr   