Hi, I've just got strange results from function pointToLineDistance when compared to nearestPointOnLine and to what should be expected. Short explanation code:
let lineCoords = [
[ 10.964832305908203, 41.004681939880314 ],
[ 10.977363586425781, 40.99096148527727 ],
[ 10.983200073242188, 40.97075154073346 ],
[ 11.02834701538086, 40.98372150040732 ],
[ 11.02508544921875, 41.00716631272605 ],
[ 10.994186401367188, 41.01947819666632 ],
[ 10.964832305908203, 41.004681939880314 ]
];
let line = turf.lineString(lineCoords);
let x0 = 11.02834;
let x1 = 11.02835;
let dx = 0.000001;
for (let i = 0, x = x0; x <= x1; i++, x = x0 + i * dx) {
let p = turf.point([ x, 41.0 ]);
let d = turf.pointToLineDistance(p, line, {units : 'meters'});
let pm = turf.nearestPointOnLine(line, p, {units : 'meters'});
console.log(turf.getCoord(p), d, pm.properties.dist);
}
The result is:
[ 11.02834, 41 ] 188.40111660891222 188.42219043739743
[ 11.028341, 41 ] 188.4845779466462 188.50565183748427
[ 11.028342, 41 ] 188.5680392846129 188.58911323788854
[ 11.028343, 41 ] 188.65150062254605 188.67257463823046
[ 11.028344, 41 ] 188.73496196071352 188.75603603901936
[ 11.028345, 41 ] 188.8184232988473 188.83949743959744
[ 11.028346, 41 ] 188.9018846372153 188.92295884065962
[ 11.028347, 41 ] 188.9853459755496 189.00642024172396
[ 11.028348, 41 ] 842.5784253401666 189.08988164279026
[ 11.028349, 41 ] 842.6056956528126 189.17334304432177
[ 11.02835, 41 ] 842.6329734397548 189.2568044457904
There is a threshold longitude for which pointToLineDistance becomes invalid.
Any suggestions?
Thanks
Hi, I've just got strange results from function pointToLineDistance when compared to nearestPointOnLine and to what should be expected. Short explanation code:
The result is:
[ 11.02834, 41 ] 188.40111660891222 188.42219043739743
[ 11.028341, 41 ] 188.4845779466462 188.50565183748427
[ 11.028342, 41 ] 188.5680392846129 188.58911323788854
[ 11.028343, 41 ] 188.65150062254605 188.67257463823046
[ 11.028344, 41 ] 188.73496196071352 188.75603603901936
[ 11.028345, 41 ] 188.8184232988473 188.83949743959744
[ 11.028346, 41 ] 188.9018846372153 188.92295884065962
[ 11.028347, 41 ] 188.9853459755496 189.00642024172396
[ 11.028348, 41 ] 842.5784253401666 189.08988164279026
[ 11.028349, 41 ] 842.6056956528126 189.17334304432177
[ 11.02835, 41 ] 842.6329734397548 189.2568044457904
There is a threshold longitude for which pointToLineDistance becomes invalid.
Any suggestions?
Thanks