From e4ada9ea2f736b92d0290c1890e0de9744da9a80 Mon Sep 17 00:00:00 2001 From: crschmidt Date: Sat, 21 Jun 2008 13:09:23 +0000 Subject: [PATCH] WKT Format reprojects geometrycollection components twice. Fixed by anonymous contributor. (Closes #1554) git-svn-id: http://svn.openlayers.org/trunk/openlayers@7413 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf --- lib/OpenLayers/Format/WKT.js | 4 +++- tests/Format/WKT.html | 23 ++++++++++++++++++++++- 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/lib/OpenLayers/Format/WKT.js b/lib/OpenLayers/Format/WKT.js index 4560ce0bb8..46ff3067a9 100644 --- a/lib/OpenLayers/Format/WKT.js +++ b/lib/OpenLayers/Format/WKT.js @@ -67,7 +67,9 @@ OpenLayers.Format.WKT = OpenLayers.Class(OpenLayers.Format, { features.CLASS_NAME == "OpenLayers.Feature.Vector") { features.geometry.transform(this.externalProjection, this.internalProjection); - } else if (features && typeof features == "object") { + } else if (features && + type != "geometrycollection" && + typeof features == "object") { for (var i = 0; i < features.length; i++) { var component = features[i]; component.geometry.transform(this.externalProjection, diff --git a/tests/Format/WKT.html b/tests/Format/WKT.html index 814723e903..29f0d2250e 100644 --- a/tests/Format/WKT.html +++ b/tests/Format/WKT.html @@ -216,8 +216,29 @@ } + function test_Format_WKT_read_projection(t) { + t.plan(1); + + var projections = { + src: new OpenLayers.Projection("EPSG:4326"), + dest: new OpenLayers.Projection("EPSG:900913") + }; + + var points = { + src: new OpenLayers.Feature.Vector(new OpenLayers.Geometry.Point(-87.9, 41.9)), + dest: new OpenLayers.Feature.Vector(new OpenLayers.Geometry.Point(-9784983.239366667, 5146011.678566458)) + }; + + var format = new OpenLayers.Format.WKT({ + externalProjection: projections["src"], + internalProjection: projections["dest"], + }); + var feature = format.read("GEOMETRYCOLLECTION(POINT(" + points["src"].geometry.x + " " + points["src"].geometry.y + "))")[0]; + t.eq(feature.geometry.toString(), points["dest"].geometry.toString(), + "Geometry collections aren't transformed twice when reprojection."); + } - \ No newline at end of file +