diff --git a/lib/OpenLayers/Format/KML.js b/lib/OpenLayers/Format/KML.js index a1c34d7d4d..5457cd0a0c 100644 --- a/lib/OpenLayers/Format/KML.js +++ b/lib/OpenLayers/Format/KML.js @@ -1223,12 +1223,6 @@ OpenLayers.Format.KML = OpenLayers.Class(OpenLayers.Format.XML, { * {DOMElement} */ buildGeometryNode: function(geometry) { - if (this.internalProjection && this.externalProjection && - !(geometry instanceof OpenLayers.Geometry.Collection)) { - geometry = geometry.clone(); - geometry.transform(this.internalProjection, - this.externalProjection); - } var className = geometry.CLASS_NAME; var type = className.substring(className.lastIndexOf(".") + 1); var builder = this.buildGeometry[type.toLowerCase()]; @@ -1413,12 +1407,12 @@ OpenLayers.Format.KML = OpenLayers.Class(OpenLayers.Format.XML, { var parts = new Array(numPoints); for(var i=0; i} + * + * Returns + * {String} a coordinate pair + */ + buildCoordinates: function(point) { + if (this.internalProjection && this.externalProjection) { + point = point.clone(); + point.transform(this.internalProjection, + this.externalProjection); + } + return point.x + "," + point.y; + }, CLASS_NAME: "OpenLayers.Format.KML" }); diff --git a/tests/Format/KML.html b/tests/Format/KML.html index c88a39fbb0..42b6fe6e0d 100644 --- a/tests/Format/KML.html +++ b/tests/Format/KML.html @@ -230,6 +230,18 @@ }; t.eq(f.read(f.write(feature))[0].attributes.name, feature.style.label, "placemark name from style.label"); } + function test_Format_KML_linestring_projected(t) { + t.plan(1); + var f = new OpenLayers.Feature.Vector(new OpenLayers.Geometry.LineString([ + new OpenLayers.Geometry.Point(15555162, 4247484), new OpenLayers.Geometry.Point(15555163, 4247485)])); + var format = new OpenLayers.Format.KML({ + 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_extractTracks(t) {