Raruto / leaflet-elevation

Leaflet plugin that allows to add elevation profiles using d3js
GNU General Public License v3.0
255 stars 85 forks source link

`imperial: true` does not calculate correct altitude values #195

Closed hupe13 closed 2 years ago

hupe13 commented 2 years ago

Hi Raruto,

hotline: "elevation",
imperial: true,

does not work, the track is displayed. in green color only If imperial is false, then it is okay.

The reason may be, that the values for altitude are not correctly calculated. I figured out how to show the values in the tooltips correctly, but the values on the y-axis and the hotline is still wrong.

hupe13 commented 2 years ago

You must change for hotline: https://github.com/Raruto/leaflet-elevation/blob/1d374c9ff0229e64c72e03214266102ceae1b42e/src/control.js#L429

let geo = L.geoJson(trkseg.toGeoJSON(), { coordsToLatLng: (coords) => L.latLng(coords[0], coords[1], coords[2]*this.options.altitudeFactor)});

for tooltip: https://github.com/Raruto/leaflet-elevation/blob/1d374c9ff0229e64c72e03214266102ceae1b42e/src/handlers/altitude.js#L57-L58

chart: (item) => L._("y: ") + _.round(item[opts.yAttr]*opts.altitudeFactor, opts.decimalsY) + " " + altitude.label,
marker: (item) => _.round(item[opts.yAttr]*opts.altitudeFactor, opts.decimalsY) + " " + altitude.label,

I would like make a pull request, but I don't know how to get the correct values on the y-axis.