o _d@stddlmZddlmZmZGdddZGdddeeZGdddeeZGd d d eeZ Gd d d eZd S))Feed) Atom1FeedRss201rev2Feedc@s,eZdZdZddZd ddZd ddZd S) GeoFeedMixinz This mixin provides the necessary routines for SyndicationFeed subclasses to produce simple GeoRSS or W3C Geo elements. cCsddd|DS)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.  css$|] }d|d|dfVqdS)z%f %frN).0coordrr:/usr/lib/python3/dist-packages/django/contrib/gis/feeds.py s"z-GeoFeedMixin.georss_coords..)join)selfcoordsrrr georss_coords szGeoFeedMixin.georss_coordsFcCsP|r|dd\}}|dd||dd|dS|d||fdS)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. Nzgeo:latz%fzgeo:lonz georss:point)addQuickElementr)rhandlerrw3c_geolonlatrrr add_georss_points zGeoFeedMixin.add_georss_pointcCsX|d}|durt|ttfred}t|dttfr(t|dkr$|}n*tdt|dkr7|j|||dnt|dkrJ|dd|ddf}ntd|durc|rXtd |d ||dSdSt |j  }|d kr{|j||j |ddS|rtd |d vr|d||j dS|dvr|d||dj dStd|j dS)z:Add a GeoRSS XML element using the given item and handler.geometryNrrz'Only should be two sets of coordinates.rz'Only should be 2 or 4 numeric elements.z.Cannot use simple GeoRSS box in W3C Geo feeds.z georss:boxpointz'W3C Geo only supports Point geometries.) linestring linearringz georss:line)polygonzgeorss:polygonz!Geometry type "%s" not supported.) get isinstancelisttuplelen ValueErrorrrrstr geom_typelowerr)rritemrgeom box_coordsgtyperrr add_georss_element s:    zGeoFeedMixin.add_georss_elementN)F)__name__ __module__ __qualname____doc__rrr,rrrr rs   rc4eZdZfddZfddZfddZZS) GeoRSSFeedct}d|d<|SNzhttp://www.georss.org/georssz xmlns:georsssuperrss_attributesrattrs __class__rr r7R zGeoRSSFeed.rss_attributesct|||||dSNr6add_item_elementsr,rrr(r:rr r@WzGeoRSSFeed.add_item_elementsct||||jdSr>r6add_root_elementsr,feedrrr:rr rE[ zGeoRSSFeed.add_root_elementsr-r.r/r7r@rE __classcell__rrr:r r2Q  r2cr1) GeoAtom1Feedcr3r4)r6root_attributesr8r:rr rMar<zGeoAtom1Feed.root_attributescr=r>r?rAr:rr r@frBzGeoAtom1Feed.add_item_elementscrCr>rDrGr:rr rEjrHzGeoAtom1Feed.add_root_elements)r-r.r/rMr@rErJrrr:r rL`rKrLcr1) W3CGeoFeedcr3)Nz(http://www.w3.org/2003/01/geo/wgs84_pos#z xmlns:geor5r8r:rr r7pr<zW3CGeoFeed.rss_attributescs"t|||j||dddSNTrr?rAr:rr r@uszW3CGeoFeed.add_item_elementscs"t||j||jdddSrOrDrGr:rr rEys zW3CGeoFeed.add_root_elementsrIrrr:r rNorKrNc@s$eZdZdZeZddZddZdS)rz 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. cCsd|d|iS)Nr_get_dynamic_attr)robjrrr feed_extra_kwargszFeed.feed_extra_kwargscCsd|d|iS)Nr item_geometryrP)rr(rrr item_extra_kwargsrTzFeed.item_extra_kwargsN)r-r.r/r0r2 feed_typerSrVrrrr rs  rN) django.contrib.syndication.viewsrBaseFeeddjango.utils.feedgeneratorrrrr2rLrNrrrr s L