Fix a Format.WKT test that failed due to rounding / precision of values.
This commit is contained in:
@@ -254,21 +254,39 @@
|
|||||||
t.plan(1);
|
t.plan(1);
|
||||||
|
|
||||||
var projections = {
|
var projections = {
|
||||||
src: new OpenLayers.Projection("EPSG:4326"),
|
src: new OpenLayers.Projection("EPSG:4326"),
|
||||||
dest: new OpenLayers.Projection("EPSG:900913")
|
dest: new OpenLayers.Projection("EPSG:900913")
|
||||||
};
|
},
|
||||||
|
points = {
|
||||||
var points = {
|
src: new OpenLayers.Feature.Vector(
|
||||||
src: new OpenLayers.Feature.Vector(new OpenLayers.Geometry.Point(-87.9, 41.9)),
|
new OpenLayers.Geometry.Point(-87.9, 41.9)
|
||||||
dest: new OpenLayers.Feature.Vector(new OpenLayers.Geometry.Point(-9784983.2393667, 5146011.6785665))
|
),
|
||||||
};
|
dest: new OpenLayers.Feature.Vector(
|
||||||
|
new OpenLayers.Geometry.Point(-9784983.2393667, 5146011.6785665)
|
||||||
var format = new OpenLayers.Format.WKT({
|
)
|
||||||
externalProjection: projections["src"],
|
},
|
||||||
internalProjection: projections["dest"]
|
format = new OpenLayers.Format.WKT({
|
||||||
});
|
externalProjection: projections["src"],
|
||||||
var feature = format.read("GEOMETRYCOLLECTION(POINT(" + points["src"].geometry.x + " " + points["src"].geometry.y + "))")[0];
|
internalProjection: projections["dest"]
|
||||||
t.eq(feature.geometry.toString(), points["dest"].geometry.toString(),
|
}),
|
||||||
|
gc_wkt_parts = [
|
||||||
|
"GEOMETRYCOLLECTION(",
|
||||||
|
"POINT(",
|
||||||
|
points["src"].geometry.x,
|
||||||
|
" ",
|
||||||
|
points["src"].geometry.y,
|
||||||
|
")",
|
||||||
|
")"
|
||||||
|
],
|
||||||
|
feature = format.read( gc_wkt_parts.join("") )[0],
|
||||||
|
gotGeom = feature.geometry,
|
||||||
|
expectGeom = points["dest"].geometry,
|
||||||
|
// we don't use geometry::toString because we might run into
|
||||||
|
// precision issues
|
||||||
|
got = gotGeom.x.toFixed(7) + ' ' + gotGeom.y.toFixed(7),
|
||||||
|
expected = expectGeom.x.toFixed(7) + ' ' + expectGeom.y.toFixed(7);
|
||||||
|
|
||||||
|
t.eq(got, expected,
|
||||||
"Geometry collections aren't transformed twice when reprojection.");
|
"Geometry collections aren't transformed twice when reprojection.");
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
Reference in New Issue
Block a user