[OpenLayers-Commits] r11647 - in trunk/openlayers:
lib/OpenLayers/Format tests/Format
commits-20090109 at openlayers.org
commits-20090109 at openlayers.org
Mon Mar 7 06:21:34 EST 2011
Author: crschmidt
Date: 2011-03-07 03:21:32 -0800 (Mon, 07 Mar 2011)
New Revision: 11647
Modified:
trunk/openlayers/lib/OpenLayers/Format/OSM.js
trunk/openlayers/tests/Format/OSM.html
Log:
Add support to Format.OSM to reproject on writing. Initial suggestion from
Arnd Wipperman, turned into a patch by me, r=bartvde (Closes #2988)
Modified: trunk/openlayers/lib/OpenLayers/Format/OSM.js
===================================================================
--- trunk/openlayers/lib/OpenLayers/Format/OSM.js 2011-03-07 11:20:12 UTC (rev 11646)
+++ trunk/openlayers/lib/OpenLayers/Format/OSM.js 2011-03-07 11:21:32 UTC (rev 11647)
@@ -347,6 +347,13 @@
'point': function(point) {
var id = null;
var geometry = point.geometry ? point.geometry : point;
+
+ if (this.internalProjection && this.externalProjection) {
+ geometry = geometry.clone();
+ geometry.transform(this.internalProjection,
+ this.externalProjection);
+ }
+
var already_exists = false; // We don't return anything if the node
// has already been created
if (point.osm_id) {
Modified: trunk/openlayers/tests/Format/OSM.html
===================================================================
--- trunk/openlayers/tests/Format/OSM.html 2011-03-07 11:20:12 UTC (rev 11646)
+++ trunk/openlayers/tests/Format/OSM.html 2011-03-07 11:21:32 UTC (rev 11647)
@@ -95,6 +95,18 @@
output = output.replace(/<\?[^>]*\?>/, '');
t.eq(output, osm_serialized_data[key], key + " serialized correctly");
}
+ }
+ function test_Format_OSM_write_reproject(t) {
+ t.plan(1);
+ var f = new OpenLayers.Format.OSM({'internalProjection': new OpenLayers.Projection("EPSG:900913")});
+ var feat = new OpenLayers.Feature.Vector(
+ new OpenLayers.Geometry.Point(100000, 100000)
+ );
+ var data = f.write([feat]);
+ var f = new OpenLayers.Format.OSM();
+ var features = f.read(data);
+
+ t.eq(OpenLayers.Util.toFloat(features[0].geometry.x, 3), .898, "exported to lonlat and re-read as lonlat correctly")
}
</script>
</head>
More information about the Commits
mailing list