[OpenLayers-Trac] Re: [OpenLayers] #3495: GPX writer
OpenLayers
trac-20090302 at openlayers.org
Wed Sep 14 18:41:24 EDT 2011
#3495: GPX writer
---------------------+------------------------------------------------------
Reporter: pgiraud | Owner:
Type: feature | Status: new
Priority: minor | Milestone: 2.12 Release
Component: general | Version: 2.11 RC3
Keywords: | State: Commit
---------------------+------------------------------------------------------
Changes (by marcjansen):
* state: Review => Commit
Comment:
Pierre,
good to have write support for GPX thanks to your work. Please commit your
latest patch.
One question, though. While looking into your patch I wrote another
testcase, that is currently failing:
{{{
function test_Format_GPX_serialize_deserialize(t) {
t.plan(3);
var parser = new OpenLayers.Format.GPX();
// create a polygon and serialize it
var point = new OpenLayers.Geometry.Point(-111.04, 45.68);
var point2 = new OpenLayers.Geometry.Point(-112.04, 45.68);
var linearRing = new OpenLayers.Geometry.LinearRing([point,
point2, point.clone()]);
var polygon = new OpenLayers.Geometry.Polygon([linearRing]);
var f = new OpenLayers.Feature.Vector(polygon, {name: 'foo',
description: 'bar'});
var data = parser.write([f]);
// now deserialize the GPX and compare with the input values
var deserialized = parser.read(data);
console.log(deserialized);
t.eq(deserialized.length, 1,
'Serialized GPX string returned exactly one element on
deserialisation.');
t.ok(deserialized[0] instanceof OpenLayers.Feature.Vector,
'Serialized GPX string returned exactly one feature on
deserialisation.');
// This fails as the track is returned as a linestring
t.ok(deserialized[0].geometry instanceof
OpenLayers.Geometry.Polygon,
'Serialized GPX string returned exactly one feature with
polygon geometry on deserialisation.');
}
}}}
(This is essentially your `test_Format_GPX_serialize_polygon(t)` only with
an added deserialisation)
When the GPX string is deserialized, the information that it once was a
polygon is lost. One might expect that any write operation should lead on
subsequent reading to the same input values. But in the particular case I
doubt whether that would make sense (You would most possibly not expect
your GPX of a roundtrip to be interpretted as a polygon, right?).
What do you think?
--
Ticket URL: <http://trac.openlayers.org/ticket/3495#comment:3>
OpenLayers <http://openlayers.org/>
A free AJAX map viewer
More information about the Trac
mailing list