You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've found an inconsistency in the results if locateOnLine and interpolateOnline.
I've tried to compute the ratio of a point along a road of 320 km ca then convert the ratio to a latlon again. There is a variable misplacement, pretty high in my opinion, it could go above 1km.
I've fixed implementing my own version of the functions
interpolateOnLine = function (map, latLngs, ratio) {
latLngs = (latLngs instanceof L.Polyline) ? latLngs.getLatLngs() : latLngs;
var maxzoom = map.getMaxZoom();
if (maxzoom === Infinity)
maxzoom = map.getZoom();
var pts = latLngs.map(function (x) {
return map.project(x);
});
if (ratio <= 0)
return latLngs[0];
if (ratio >= 1)
return latLngs[latLngs - 1];
var dt = 0.;
for (var i = 1; i < pts.length; i++)
dt += pts[i - 1].distanceTo(pts[i]);
var dp = dt * ratio;
var dt = 0.;
for (var i = 1; i < pts.length; i++)
{
var d = pts[i - 1].distanceTo(pts[i]);
if (dt + d > dp)
{
//console.log((dp-dt)/d);
var p = L.GeometryUtil.interpolateOnPointSegment(pts[i - 1], pts[i], (dp - dt) / d);
return map.unproject(p);
}
dt += d;
}
return latLngs[latLngs - 1];
};
locateOnLine = function (map, polyline, latlng) {
var maxzoom = map.getMaxZoom();
if (maxzoom === Infinity)
maxzoom = map.getZoom();
var pts = polyline.getLatLngs().map(function (x) {
return map.project(x);
});
var point = map.project(L.GeometryUtil.closest(map, polyline, latlng, false));
var d = 0.;
var dt = 0.;
for (var i = 1; i < pts.length; i++)
{
var dd = pts[i - 1].distanceTo(pts[i]);
if (L.GeometryUtil.belongsSegment(point, pts[i - 1], pts[i], 0.0001))
d = dt + pts[i - 1].distanceTo(point);
dt += dd;
}
return d / dt;
};
I've tested converting latlon to ratio to latlon to ratio .... till 10 times and now it seems to be very stable and consistent
PLEASE NOTE THAT interpolateOnLine here is not returning the precedent point , just the interpolated one
The text was updated successfully, but these errors were encountered:
I've found an inconsistency in the results if locateOnLine and interpolateOnline.
I've tried to compute the ratio of a point along a road of 320 km ca then convert the ratio to a latlon again. There is a variable misplacement, pretty high in my opinion, it could go above 1km.
I've fixed implementing my own version of the functions
I've tested converting latlon to ratio to latlon to ratio .... till 10 times and now it seems to be very stable and consistent
PLEASE NOTE THAT interpolateOnLine here is not returning the precedent point , just the interpolated one
The text was updated successfully, but these errors were encountered: