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) git-svn-id: http://svn.openlayers.org/trunk/openlayers@11644 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
@@ -1222,7 +1222,8 @@ OpenLayers.Format.KML = OpenLayers.Class(OpenLayers.Format.XML, {
|
||||
* {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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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>';
|
||||
|
||||
Reference in New Issue
Block a user