Permalink
Browse files

Added lat-long support and tests for GeoRSS-Simple

  • Loading branch information...
1 parent ee4f756 commit 3340c3a940cc377e70505ffc40f0ec5f0fd7b3c8 @mortenf mortenf committed Oct 20, 2010
View
@@ -304,6 +304,21 @@ def reconstitute(feed, entry):
if entry.has_key('geo_lat') and \
entry.has_key('geo_long'):
location(xentry, (float)(entry.get('geo_long',None)), (float)(entry.get('geo_lat',None)))
+ if entry.has_key('georss_point'):
+ coordinates = re.split('[,\s]', entry.get('georss_point'))
+ location(xentry, (float)(coordinates[1]), (float)(coordinates[0]))
+ elif entry.has_key('georss_line'):
+ coordinates = re.split('[,\s]', entry.get('georss_line'))
+ location(xentry, (float)(coordinates[1]), (float)(coordinates[0]))
+ elif entry.has_key('georss_circle'):
+ coordinates = re.split('[,\s]', entry.get('georss_circle'))
+ location(xentry, (float)(coordinates[1]), (float)(coordinates[0]))
+ elif entry.has_key('georss_box'):
+ coordinates = re.split('[,\s]', entry.get('georss_box'))
+ location(xentry, ((float)(coordinates[1])+(float)(coordinates[3]))/2, ((float)(coordinates[0])+(float)(coordinates[2]))/2)
+ elif entry.has_key('georss_polygon'):
+ coordinates = re.split('[,\s]', entry.get('georss_polygon'))
+ location(xentry, (float)(coordinates[1]), (float)(coordinates[0]))
# author / contributor
author_detail = entry.get('author_detail',{})
@@ -0,0 +1,10 @@
+<!--
+Description: box inside an entry (center point calculated)
+Expect: geo_lat == '42.991000' and geo_long == '-70.444000'
+-->
+
+<feed xmlns="http://www.w3.org/2005/Atom">
+ <entry>
+ <georss:box>42.943 -71.032 43.039 -69.856</georss:box>
+ </entry>
+</feed>
@@ -0,0 +1,15 @@
+<!--
+Description: polygon inside bounding box inside place inside an entry
+Expect: geo_lat == '34.052610' and geo_long == '-118.432212'
+-->
+
+<feed xmlns="http://www.w3.org/2005/Atom"
+ xmlns:twitter="http://api.twitter.com">
+ <entry>
+ <twitter:place xmlns:georss="http://www.georss.org/georss">
+ <twitter:bounding_box>
+ <georss:polygon>34.05260997 -118.43221212 34.05260997 -118.37216196 34.11240804 -118.37216196 34.11240804 -118.43221212</georss:polygon>
+ </twitter:bounding_box>
+ </twitter:place>
+ </entry>
+</feed>
@@ -0,0 +1,11 @@
+<!--
+Description: point inside an entry
+Expect: geo_lat == '34.101646' and geo_long == '-118.326454'
+-->
+
+<feed xmlns="http://www.w3.org/2005/Atom"
+ xmlns:twitter="http://api.twitter.com">
+ <entry>
+ <georss:point>34.10164620,-118.32645359</georss:point>
+ </entry>
+</feed>
@@ -0,0 +1,10 @@
+<!--
+Description: polygon inside an entry
+Expect: geo_lat == '34.052610' and geo_long == '-118.432212'
+-->
+
+<feed xmlns="http://www.w3.org/2005/Atom">
+ <entry>
+ <georss:polygon>34.052610 -118.432212 34.05260997 -118.37216196 34.11240804 -118.37216196 34.11240804 -118.43221212</georss:polygon>
+ </entry>
+</feed>

0 comments on commit 3340c3a

Please sign in to comment.