From 60d4b11499d56824832fa3009b0a99e0a6b3d949 Mon Sep 17 00:00:00 2001 From: Amaury Zarzelli Date: Wed, 18 Dec 2024 14:50:11 +0100 Subject: [PATCH] fix profil alti trop gros https://github.com/IGNF/geopf-extensions-openlayers/pull/303 --- src/OpenLayers/Controls/ElevationPath.js | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/OpenLayers/Controls/ElevationPath.js b/src/OpenLayers/Controls/ElevationPath.js index 386e872b..d859ea3b 100644 --- a/src/OpenLayers/Controls/ElevationPath.js +++ b/src/OpenLayers/Controls/ElevationPath.js @@ -1384,8 +1384,10 @@ var ElevationPath = (function (Control) { // Calcul de la distance au départ pour chaque point + arrondi des lat/lon _data[0].dist = 0; _data[0].slope = 0; - _data[0].lat = Math.round(_data[0].lat * 10000) / 10000; - _data[0].lon = Math.round(_data[0].lon * 10000) / 10000; + _data[0].oldlat = _data[0].lat; + _data[0].oldlon = _data[0].lon; + _data[0].lat = Math.round(_data[0].lat * 100000) / 100000; + _data[0].lon = Math.round(_data[0].lon * 100000) / 100000; var _distanceMinus = 0; var _distancePlus = 0; @@ -1398,7 +1400,7 @@ var ElevationPath = (function (Control) { for (var i = 1; i < _data.length; i++) { var a = [_data[i].lon, _data[i].lat]; - var distanceToPrevious = olGetDistanceSphere(a, [_data[i-1].lon, _data[i-1].lat]); + var distanceToPrevious = olGetDistanceSphere(a, [_data[i-1].oldlon, _data[i-1].oldlat]); var dist = distanceToPrevious + _distance; var za = _data[i].z; @@ -1439,8 +1441,10 @@ var ElevationPath = (function (Control) { _data[i].color = "#00B798"; } - _data[i].lat = Math.round(_data[i].lat * 10000) / 10000; - _data[i].lon = Math.round(_data[i].lon * 10000) / 10000; + _data[i].oldlat = _data[i].lat; + _data[i].oldlon = _data[i].lon; + _data[i].lat = Math.round(_data[i].lat * 100000) / 100000; + _data[i].lon = Math.round(_data[i].lon * 100000) / 100000; } // check distance totale