Skip to content

Commit

Permalink
geodesicConvertLine: calculate seg count based on distance
Browse files Browse the repository at this point in the history
Suggested by @johnd0e in IITC-CE/ingress-intel-total-conversion#232 (comment). Should work for now, at least until we switch to the shinier Geodesic addon by henrythasler.
  • Loading branch information
Artoria2e5 authored May 28, 2024
1 parent c9f84ab commit 6474f4b
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/L.Geodesic.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@
var lng2 = end.lng * d2r;
var dLng = lng1-lng2;

var segments = Math.floor(Math.abs(dLng * earthR / this.options.segmentsCoeff));
var distance = Math.acos(
Math.sin(lat1) * Math.sin(lat2) +
Math.cos(lat1) * Math.cos(lat2) * Math.cos(-dLng));
var segments = Math.ceil(distance * earthR / segmentLength);
if (segments < 2) { return; }

// maths based on https://edwilliams.org/avform.htm#Int
Expand Down

0 comments on commit 6474f4b

Please sign in to comment.