Closed agwells closed 4 years ago
You are quite correct!
Thank you, I will fix that.
I also tried LatLonNvectorSpherical
. It also returns NaN
for crossTrackDistance()
, while alongTrackDistance()
returns a very small non-zero float.
import LatLonNvectorSpherical from 'geodesy/latlon-nvector-spherical';
const p1 = new LatLonNvectorSpherical(10, 20);
const p1a = new LatLonNvectorSpherical(10, 20);
const pB = new LatLonNvectorSpherical(11, 21);
console.log(p1.distanceTo(p1a)); // 0
console.log(p1.alongTrackDistanceTo(p1a, pB)); // 6.799437946888028e-10
console.log(p1.crossTrackDistanceTo(p1a, pB)); // NaN
Fixed in v2.2.1.
Thanks for sharing this great library! :)
I've noticed that using the
LatLonSpherical
class'sthis.alongTrackDistanceTo()
andthis.crossTrackDistanceTo()
, if thethis
point is the same location as the starting point parameter, the methods returnNaN
rather than the expected0
.Example:
Expected result:
I expected both operations to return numeric
0
rather thanNaN
. This makes sense intuitively, and it would be consistent with the behavior of the.distanceTo()
method, which returns a distance of0
from one location to the same location.