Merge pull request #6893 from tchandelle/decimals

Fix decimals options when writing features
This commit is contained in:
Andreas Hocevar
2017-06-09 09:27:08 +02:00
committed by GitHub
2 changed files with 21 additions and 8 deletions

View File

@@ -183,14 +183,14 @@ ol.format.Feature.transformWithOptions = function(
// FIXME this is necessary because ol.format.GML treats extents
// as geometries
transformed = ol.proj.transformExtent(
write ? geometry.slice() : geometry,
write ? featureProjection : dataProjection,
write ? dataProjection : featureProjection);
geometry,
dataProjection,
featureProjection);
}
} else {
transformed = geometry;
}
if (write && opt_options && opt_options.decimals) {
if (write && opt_options && opt_options.decimals !== undefined) {
var power = Math.pow(10, opt_options.decimals);
// if decimals option on write, round each coordinate appropriately
/**
@@ -203,11 +203,10 @@ ol.format.Feature.transformWithOptions = function(
}
return coordinates;
};
if (Array.isArray(transformed)) {
transform(transformed);
} else {
transformed.applyTransform(transform);
if (transformed === geometry) {
transformed = transformed.clone();
}
transformed.applyTransform(transform);
}
return transformed;
};