Skip to content

Commit

Permalink
fix: added getLength decimal precision for non geodesic map
Browse files Browse the repository at this point in the history
BREAKING CHANGE: change default decimal precision to 10^6
  • Loading branch information
bdachary committed Sep 13, 2023
1 parent f36ffc8 commit 622c40a
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/MeasureUtil/MeasureUtil.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,15 @@ class MeasureUtil {
* @return {number} The length of line in meters.
*/
static getLength(line: OlGeomLineString, map: OlMap, geodesic: boolean = true, radius: number = 6371008.8): number {
const decimalPrecision = Math.pow(10, 6);
if (geodesic) {
const opts = {
projection: map.getView().getProjection().getCode(),
radius
};
return getLength(line, opts);
} else {
return Math.round(line.getLength() * 100) / 100;
return Math.round(line.getLength() * decimalPrecision) / decimalPrecision;
}
}

Expand Down

0 comments on commit 622c40a

Please sign in to comment.