Set GeometryLayout correctly when reading GPX

Fixes #6148
This commit is contained in:
Roman Zoller
2016-11-21 17:47:41 +01:00
parent caef2b51b4
commit f56b2c8a75
3 changed files with 90 additions and 27 deletions

View File

@@ -42,7 +42,7 @@ describe('ol.format.GPX', function() {
var g = f.getGeometry();
expect(g).to.be.an(ol.geom.LineString);
expect(g.getCoordinates()).to.eql([]);
expect(g.getLayout()).to.be('XYZM');
expect(g.getLayout()).to.be('XY');
});
it('can read and write various rte attributes', function() {
@@ -98,8 +98,8 @@ describe('ol.format.GPX', function() {
expect(f).to.be.an(ol.Feature);
var g = f.getGeometry();
expect(g).to.be.an(ol.geom.LineString);
expect(g.getCoordinates()).to.eql([[2, 1, 0, 0], [4, 3, 0, 0]]);
expect(g.getLayout()).to.be('XYZM');
expect(g.getCoordinates()).to.eql([[2, 1], [4, 3]]);
expect(g.getLayout()).to.be('XY');
var serialized = format.writeFeaturesNode(fs);
expect(serialized).to.xmleql(ol.xml.parse(text));
});
@@ -124,11 +124,9 @@ describe('ol.format.GPX', function() {
var g = f.getGeometry();
expect(g).to.be.an(ol.geom.LineString);
var p1 = ol.proj.transform([2, 1], 'EPSG:4326', 'EPSG:3857');
p1.push(0, 0);
var p2 = ol.proj.transform([6, 5], 'EPSG:4326', 'EPSG:3857');
p2.push(0, 0);
expect(g.getCoordinates()).to.eql([p1, p2]);
expect(g.getLayout()).to.be('XYZM');
expect(g.getLayout()).to.be('XY');
var serialized = format.writeFeaturesNode(fs, {
featureProjection: 'EPSG:3857'
});
@@ -168,7 +166,7 @@ describe('ol.format.GPX', function() {
var g = f.getGeometry();
expect(g).to.be.an(ol.geom.MultiLineString);
expect(g.getCoordinates()).to.eql([]);
expect(g.getLayout()).to.be('XYZM');
expect(g.getLayout()).to.be('XY');
});
it('can read and write various trk attributes', function() {
@@ -224,7 +222,7 @@ describe('ol.format.GPX', function() {
var g = f.getGeometry();
expect(g).to.be.an(ol.geom.MultiLineString);
expect(g.getCoordinates()).to.eql([[]]);
expect(g.getLayout()).to.be('XYZM');
expect(g.getLayout()).to.be('XY');
var serialized = format.writeFeaturesNode(fs);
expect(serialized).to.xmleql(ol.xml.parse(text));
});
@@ -398,8 +396,8 @@ describe('ol.format.GPX', function() {
expect(f).to.be.an(ol.Feature);
var g = f.getGeometry();
expect(g).to.be.an(ol.geom.Point);
expect(g.getCoordinates()).to.eql([2, 1, 0, 0]);
expect(g.getLayout()).to.be('XYZM');
expect(g.getCoordinates()).to.eql([2, 1]);
expect(g.getLayout()).to.be('XY');
var serialized = format.writeFeaturesNode(fs);
expect(serialized).to.xmleql(ol.xml.parse(text));
});
@@ -421,9 +419,8 @@ describe('ol.format.GPX', function() {
var g = f.getGeometry();
expect(g).to.be.an(ol.geom.Point);
var expectedPoint = ol.proj.transform([2, 1], 'EPSG:4326', 'EPSG:3857');
expectedPoint.push(0, 0);
expect(g.getCoordinates()).to.eql(expectedPoint);
expect(g.getLayout()).to.be('XYZM');
expect(g.getLayout()).to.be('XY');
var serialized = format.writeFeaturesNode(fs, {
featureProjection: 'EPSG:3857'
});
@@ -446,8 +443,8 @@ describe('ol.format.GPX', function() {
expect(f).to.be.an(ol.Feature);
var g = f.getGeometry();
expect(g).to.be.an(ol.geom.Point);
expect(g.getCoordinates()).to.eql([2, 1, 3, 0]);
expect(g.getLayout()).to.be('XYZM');
expect(g.getCoordinates()).to.eql([2, 1, 3]);
expect(g.getLayout()).to.be('XYZ');
var serialized = format.writeFeaturesNode(fs);
expect(serialized).to.xmleql(ol.xml.parse(text));
});
@@ -468,8 +465,8 @@ describe('ol.format.GPX', function() {
expect(f).to.be.an(ol.Feature);
var g = f.getGeometry();
expect(g).to.be.an(ol.geom.Point);
expect(g.getCoordinates()).to.eql([2, 1, 0, 1263115752]);
expect(g.getLayout()).to.be('XYZM');
expect(g.getCoordinates()).to.eql([2, 1, 1263115752]);
expect(g.getLayout()).to.be('XYM');
var serialized = format.writeFeaturesNode(fs);
expect(serialized).to.xmleql(ol.xml.parse(text));
});