abdera-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jmsn...@apache.org
Subject svn commit: r564812 - /incubator/abdera/java/trunk/extensions/src/main/java/org/apache/abdera/ext/geo/GeoHelper.java
Date Sat, 11 Aug 2007 00:40:23 GMT
Author: jmsnell
Date: Fri Aug 10 17:40:22 2007
New Revision: 564812

URL: http://svn.apache.org/viewvc?view=rev&rev=564812
Log:
Tweak to support the W3C encoding Point element.  This let's us read the flickr geotagged
atom feeds

Modified:
    incubator/abdera/java/trunk/extensions/src/main/java/org/apache/abdera/ext/geo/GeoHelper.java

Modified: incubator/abdera/java/trunk/extensions/src/main/java/org/apache/abdera/ext/geo/GeoHelper.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/extensions/src/main/java/org/apache/abdera/ext/geo/GeoHelper.java?view=diff&rev=564812&r1=564811&r2=564812
==============================================================================
--- incubator/abdera/java/trunk/extensions/src/main/java/org/apache/abdera/ext/geo/GeoHelper.java
(original)
+++ incubator/abdera/java/trunk/extensions/src/main/java/org/apache/abdera/ext/geo/GeoHelper.java
Fri Aug 10 17:40:22 2007
@@ -36,6 +36,7 @@
   public static final String SIMPLE_GEO_NS = "http://www.georss.org/georss/10";
   public static final String GML_NS = "http://www.opengis.net/gml";
   
+  public static final QName QNAME_W3C_POINT = new QName(W3C_GEO_NS, "Point", "geo");
   public static final QName QNAME_W3C_LAT = new QName(W3C_GEO_NS, "lat", "geo");
   public static final QName QNAME_W3C_LONG = new QName(W3C_GEO_NS, "long", "geo");
   
@@ -157,8 +158,11 @@
     el = entry.getExtension(QNAME_W3C_LONG);
     if (el != null) el.discard();    
     Point point = (Point) position;
-    entry.addSimpleExtension(QNAME_W3C_LAT, Double.toString(point.getCoordinate().getLatitude()));
-    entry.addSimpleExtension(QNAME_W3C_LONG, Double.toString(point.getCoordinate().getLongitude()));
+    
+    ExtensibleElement p = entry.addExtension(QNAME_W3C_POINT);
+    p.addSimpleExtension(QNAME_W3C_LAT, Double.toString(point.getCoordinate().getLatitude()));
+    p.addSimpleExtension(QNAME_W3C_LONG, Double.toString(point.getCoordinate().getLongitude()));
+    
   }
   
   private static List<Position> _getPositions(Entry entry) {
@@ -175,6 +179,7 @@
     if (entry.getExtensions(QNAME_SIMPLE_BOX).size() > 0) return true;
     if (entry.getExtensions(QNAME_SIMPLE_POLYGON).size() > 0) return true;
     if (entry.getExtensions(QNAME_WHERE).size() > 0) return true;
+    if (entry.getExtensions(QNAME_W3C_POINT).size() > 0) return true;
     if (entry.getExtensions(QNAME_W3C_LAT).size() > 0 && 
         entry.getExtensions(QNAME_W3C_LONG).size() > 0) return true;
     return false;
@@ -298,8 +303,14 @@
   }
   
   private static void getW3CPosition(Entry entry, List<Position> list) {
-    String slat = entry.getSimpleExtension(QNAME_W3C_LAT);
-    String slong = entry.getSimpleExtension(QNAME_W3C_LONG);
+    getW3CPosition((ExtensibleElement)entry, list);
+    List<ExtensibleElement> points = entry.getExtensions(QNAME_W3C_POINT);
+    for (ExtensibleElement point : points) getW3CPosition(point, list);
+  }
+  
+  private static void getW3CPosition(ExtensibleElement el, List<Position> list) {
+    String slat = el.getSimpleExtension(QNAME_W3C_LAT);
+    String slong = el.getSimpleExtension(QNAME_W3C_LONG);
     if (slat != null && slong != null) {
       Point point = new Point(slat.trim() + " " + slong.trim());
       list.add(point);



Mime
View raw message