Add decimals option to format write

This commit is contained in:
Peter Robins
2016-03-17 19:46:22 +00:00
parent e742181fe9
commit a18bf636f8
3 changed files with 66 additions and 4 deletions

View File

@@ -746,6 +746,26 @@ describe('ol.format.GeoJSON', function() {
expect(geometries[1].getCoordinates()[0][1]).to.roughlyEqual(
gotGeometries[1].getCoordinates()[0][1], 1e-8);
});
it('truncates transformed point with decimals option', function() {
var point = new ol.geom.Point([2, 3]).transform('EPSG:4326','EPSG:3857');
var geojson = format.writeGeometry(point, {
featureProjection: 'EPSG:3857',
decimals: 2
});
expect(format.readGeometry(geojson).getCoordinates()).to.eql(
[2, 3]);
});
it('truncates a linestring with decimals option', function() {
var linestring = new ol.geom.LineString([[42.123456789, 38.987654321],
[43, 39]]);
var geojson = format.writeGeometry(linestring, {
decimals: 6
});
expect(format.readGeometry(geojson).getCoordinates()).to.eql(
[[42.123457, 38.987654], [43, 39]]);
});
});
});