[OpenLayers-Commits] r11644 - in trunk/openlayers: lib/OpenLayers/Format tests/Format

commits-20090109 at openlayers.org commits-20090109 at openlayers.org
Mon Mar 7 06:15:21 EST 2011


Author: crschmidt
Date: 2011-03-07 03:15:20 -0800 (Mon, 07 Mar 2011)
New Revision: 11644

Modified:
   trunk/openlayers/lib/OpenLayers/Format/KML.js
   trunk/openlayers/tests/Format/GeoJSON.html
   trunk/openlayers/tests/Format/KML.html
Log:
Fix the double-reprojection of components of a collection in KML, and write a
test for it in both GeoJSON and KML to demonstrate that it works. r=bartvde,
(Closes #2040)


Modified: trunk/openlayers/lib/OpenLayers/Format/KML.js
===================================================================
--- trunk/openlayers/lib/OpenLayers/Format/KML.js	2011-03-07 10:29:32 UTC (rev 11643)
+++ trunk/openlayers/lib/OpenLayers/Format/KML.js	2011-03-07 11:15:20 UTC (rev 11644)
@@ -1222,7 +1222,8 @@
      * {DOMElement}
      */
     buildGeometryNode: function(geometry) {
-        if (this.internalProjection && this.externalProjection) {
+        if (this.internalProjection && this.externalProjection && 
+            !(geometry instanceof OpenLayers.Geometry.Collection)) {
             geometry = geometry.clone();
             geometry.transform(this.internalProjection, 
                                this.externalProjection);

Modified: trunk/openlayers/tests/Format/GeoJSON.html
===================================================================
--- trunk/openlayers/tests/Format/GeoJSON.html	2011-03-07 10:29:32 UTC (rev 11643)
+++ trunk/openlayers/tests/Format/GeoJSON.html	2011-03-07 11:15:20 UTC (rev 11644)
@@ -95,6 +95,19 @@
         t.eq(data.components[1].y, 1, "y of second component is right");    
     }
 
+    function test_Format_GeoJSON_multipoint_projected(t) {
+        t.plan(1);
+        var f = new OpenLayers.Feature.Vector(new OpenLayers.Geometry.MultiPoint([
+            new OpenLayers.Geometry.Point(15555162, 4247484)]));
+        var format = new OpenLayers.Format.GeoJSON({
+            internalProjection: new OpenLayers.Projection("EPSG:900913"),
+            externalProjection: new OpenLayers.Projection("EPSG:4326")
+        });
+        var data = format.write(f);
+        var found = (data.search('139.734') != -1);
+        t.ok(found, "Found 139.734 (correct reprojection) in data output.");
+    }        
+
     function test_Format_GeoJSON_multiline(t) {
         t.plan(3);
 

Modified: trunk/openlayers/tests/Format/KML.html
===================================================================
--- trunk/openlayers/tests/Format/KML.html	2011-03-07 10:29:32 UTC (rev 11643)
+++ trunk/openlayers/tests/Format/KML.html	2011-03-07 11:15:20 UTC (rev 11644)
@@ -9,7 +9,6 @@
     var test_style_outline = '<kml xmlns="http://earth.google.com/kml/2.0"> <Placemark>    <Style> <PolyStyle> <outline>0</outline> <color>870000ff</color> <width>10</width> </PolyStyle> </Style>  <LineString> <coordinates> -112,36 -113,37 </coordinates> </LineString> </Placemark></kml>';
     var test_style_font = '<kml xmlns="http://earth.google.com/kml/2.0"> <Placemark><Style><LabelStyle><color>870000ff</color><scale>1.5</scale></LabelStyle></Style><LineString><coordinates> -112,36 -113,37 </coordinates></LineString></Placemark></kml>';
     var test_nl = '<kml xmlns="http://earth.google.com/kml/2.2"> <Document> <NetworkLink> <Link> <href>http://maker.geocommons.com/maps/1717/overlays/0</href> </Link> </NetworkLink> </Document></kml>';
-
     function test_Format_KML_constructor(t) { 
         t.plan(5); 
          
@@ -23,7 +22,20 @@
         t.eq(format.externalProjection.getCode(), "EPSG:4326", 
              "default external projection is EPSG:4326"); 
     }
-
+    function test_Format_KML_multipoint(t) {
+        t.plan(1);
+        var f = new OpenLayers.Feature.Vector(new OpenLayers.Geometry.MultiPoint([
+            new OpenLayers.Geometry.Point(15555162, 4247484)]));
+        var format = new OpenLayers.Format.KML({
+            extractStyles:      true, 
+            extractAttributes:  true,
+            internalProjection: new OpenLayers.Projection("EPSG:900913"),
+            externalProjection: new OpenLayers.Projection("EPSG:4326")
+        });
+        var data = format.write(f);
+        var found = (data.search('139.734') != -1);
+        t.ok(found, "Found 139.734 (correct reprojection) in data output.");
+    }        
     function test_Format_KML_read(t) {
         t.plan(5);
         var features = (new OpenLayers.Format.KML()).read(this.test_content);
@@ -35,6 +47,7 @@
              "read geometry collection");
     }
 
+    
     function test_Format_KML_readCdataAttributes_20(t) {
         t.plan(2);
         var cdata = '<kml xmlns="http://earth.google.com/kml/2.0"><Document><Placemark><name><![CDATA[Pezinok]]> </name><description><![CDATA[Full of text.]]></description><styleUrl>#rel1.0</styleUrl><Point> <coordinates>17.266666, 48.283333</coordinates></Point></Placemark></Document></kml>';



More information about the Commits mailing list