Advertisement
Tarferi

About trilaterating

Jun 1st, 2020
1,475
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var resGeom = [], trialt;
  2.  
  3. function GeoIntersectCircles(a, b, c, h) {
  4.     var f = GeodesicInverse(a, c);
  5.     if (Math.abs(b + h - f.dist) < 1 || Math.abs(Math.abs(b - h) - f.dist) < 1) {
  6.         return [GeodesicDirect(a, f.startbrng, b)]
  7.     }
  8.     if (f.dist < Math.abs(b - h) || f.dist > b + h) {
  9.         return null
  10.     }
  11.     var d = toXyz(a);
  12.     var i = toXyz(c);
  13.     var j = toXyz(GeodesicDirect(a, 0, b));
  14.     var l = toXyz(GeodesicDirect(c, 0, h));
  15.     var k = Math.sqrt((d.x - j.x) * (d.x - j.x) + (d.y - j.y) * (d.y - j.y) + (d.z - j.z) * (d.z - j.z));
  16.     var n = Math.sqrt((i.x - l.x) * (i.x - l.x) + (i.y - l.y) * (i.y - l.y) + (i.z - l.z) * (i.z - l.z));
  17.     var m = d.y * i.z - i.y * d.z;
  18.     var o = d.z * i.x - i.z * d.x;
  19.     var q = d.x * i.y - i.x * d.y;
  20.     var p = m * m + o * o + q * q;
  21.     if (p === 0) {
  22.         return null
  23.     }
  24.     var r = d.x * (81179511356162 - n * n) - i.x * (81179511356162 - k * k);
  25.     var s = d.y * (81179511356162 - n * n) - i.y * (81179511356162 - k * k);
  26.     var t = d.z * (81179511356162 - n * n) - i.z * (81179511356162 - k * k);
  27.     var w = 162359022712324 * p - (s * s + t * t + r * r);
  28.     if (w < 0) {
  29.         return null
  30.     }
  31.     var z = (o * t - q * s + m * Math.sqrt(w)) / (2 * p);
  32.     var v = (q * r - m * t + o * Math.sqrt(w)) / (2 * p);
  33.     var u = (m * s - o * r + q * Math.sqrt(w)) / (2 * p);
  34.     var A = (o * t - q * s - m * Math.sqrt(w)) / (2 * p);
  35.     var B = (q * r - m * t - o * Math.sqrt(w)) / (2 * p);
  36.     var C = (m * s - o * r - q * Math.sqrt(w)) / (2 * p);
  37.     var D = Math.asin(u / Math.sqrt(z * z + v * v + u * u)) * 180 / Math.PI;
  38.     var y = Math.atan2(v, z) * 180 / Math.PI;
  39.     var x = Math.asin(C / Math.sqrt(A * A + B * B + C * C)) * 180 / Math.PI;
  40.     var G = Math.atan2(B, A) * 180 / Math.PI;
  41.     var E, H, F;
  42.     for (E = 0; E < 10; E++) {
  43.         d = AzimuthalEquidistantForward(D, y, a.lat, a.lng);
  44.         i = AzimuthalEquidistantForward(D, y, c.lat, c.lng);
  45.         F = intersectCirclesEAP(d, b, i, h);
  46.         H = AzimuthalEquidistantReverse(D, y, F.x, F.y);
  47.         D = H.lat;
  48.         y = H.lng
  49.     }
  50.     for (E = 0; E < 10; E++) {
  51.         d = AzimuthalEquidistantForward(x, G, a.lat, a.lng);
  52.         i = AzimuthalEquidistantForward(x, G, c.lat, c.lng);
  53.         F = intersectCirclesEAP(d, b, i, h);
  54.         H = AzimuthalEquidistantReverse(x, G, F.x, F.y);
  55.         x = H.lat;
  56.         G = H.lng
  57.     }
  58.     return [{
  59.         'lat': D,
  60.         'lng': y
  61.     }, {
  62.         'lat': x,
  63.         'lng': G
  64.     }]
  65. }
  66.  
  67. function GeodesicDirect(a, b, c) {
  68.     var h = geod.Direct(a.lat, a.lng, b, c);
  69.     if (h.azi2 < 0) {
  70.         h.azi2 += 360
  71.     }
  72.     return {
  73.         'lat': h.lat2,
  74.         'lng': h.lon2,
  75.         'startbrng': b,
  76.         'endbrng': h.azi2
  77.     }
  78. }
  79.  
  80. function calcIntersectCircle3(lat1, lon1, dist1, lat2, lon2, dist2, lat3, lon3, dist3) {
  81.    
  82.     var b ={lat:lat1,lng:lon1};
  83.     var c ={lat:lat2,lng:lon2};
  84.     var h ={lat:lat3,lng:lon3};
  85.    
  86.     var f = dist1
  87.     var d = dist2
  88.     var i = dist3
  89.     if (!isFinite(f) || !isFinite(d) || !isFinite(i) || f === 0 || d === 0 || i === 0) {
  90.         showResult([s_invoerfout]);
  91.         return
  92.     }
  93.     trueCircle(b, f, '#00f');
  94.     trueCircle(c, d, '#00f');
  95.     trueCircle(h, i, '#00f');
  96. // var j = [s_middelpunt_cirkel + ' A', formatCoords(b), s_straal + ' A', formatDist(f), s_middelpunt_cirkel + ' B', formatCoords(c), s_straal + ' B', formatDist(d), s_middelpunt_cirkel + ' C', formatCoords(h), s_straal + ' C', formatDist(i)];
  97.     var l = GeoIntersectCircles(b, f, c, d);
  98.     var k = GeoIntersectCircles(b, f, h, i);
  99.     var n = GeoIntersectCircles(c, d, h, i);
  100.     if (!l || !k || !n) {
  101.     // j.push(s_geen_snijpunten)
  102.     } else {
  103.         var a = l;
  104.         var b = k;
  105.         var c = n;
  106.        
  107.         var min = -1;
  108.         var combo = [];
  109.        
  110.         for(var x = 0; x < a.length; x++) {
  111.             var A = a[x];
  112.             for(var y = 0; y < b.length; y++) {
  113.                 var B = b[y];
  114.                
  115.                 var d1 = GeodesicInverse(A, B)["dist"];
  116.                
  117.                 for(var z = 0; z < c.length; z++) {
  118.                     var C=c[z];
  119.                
  120.                     var d2 = GeodesicInverse(A, C)["dist"];
  121.                    
  122.                     var d3 = GeodesicInverse(A, B)["dist"];
  123.                    
  124.                     var dists = d1+d2+d3;
  125.                    
  126.                     if(min == -1 || dists < min){
  127.                         min =dists;
  128.                         combo = [A,B,C];
  129.                     }
  130.                 }
  131.             }  
  132.         }
  133.        
  134.         if(min >= 0) {
  135.             var lat =( combo[0]["lat"] + combo[1]["lat"] + combo[2]["lat"])/3;
  136.             var lng =( combo[0]["lng"] + combo[1]["lng"] + combo[2]["lng"])/3;
  137.            
  138.             console.log(lat+" "+lng);
  139.         }
  140.         return
  141.        
  142.         var m = [], o;
  143.         if (GeodesicInverse(l[0], h).dist <= i) {
  144.             m.push(l[0])
  145.         }
  146.         if (l.length == 2 && GeodesicInverse(l[1], h).dist <= i) {
  147.             m.push(l[1])
  148.         }
  149.         if (GeodesicInverse(k[0], c).dist <= d) {
  150.             m.push(k[0])
  151.         }
  152.         if (k.length == 2 && GeodesicInverse(k[1], c).dist <= d) {
  153.             m.push(k[1])
  154.         }
  155.         if (GeodesicInverse(n[0], b).dist <= f) {
  156.             m.push(n[0])
  157.         }
  158.         if (n.length == 2 && GeodesicInverse(n[1], b).dist <= f) {
  159.             m.push(n[1])
  160.         }
  161.         if (m.length === 1) {
  162.             o = m[0]
  163.         } else if (m.length === 2) {
  164.             o = midPoint(m[0], m[1]);
  165.             trueLine(m[0], m[1], '#f00')
  166.         } else if (m.length === 3) {
  167.             trueLine(m[0], m[1], '#0f0');
  168.             trueLine(m[0], m[2], '#0f0');
  169.             trueLine(m[1], m[2], '#0f0');
  170.             o = triCen(m[0], m[1], m[2], '#f00', true)
  171.         } else if (m.length === 4) {
  172.             o = quadCen(m, '#0f0', '#0ff', true).gravcen
  173.         } else {
  174.             var q;
  175.             if (l.length == 2 && k.length == 2 && n.length == 2) {
  176.                 q = GeoIntersect([l[0], l[1], k[0], k[1]]);
  177.                 if (q) {
  178.                     var p = [];
  179.                     p.push(GeodesicInverse(q.intersection, l[0]).dist < GeodesicInverse(q.intersection, l[1]).dist ? l[0] : l[1]);
  180.                     p.push(GeodesicInverse(q.intersection, k[0]).dist < GeodesicInverse(q.intersection, k[1]).dist ? k[0] : k[1]);
  181.                     p.push(GeodesicInverse(q.intersection, n[0]).dist < GeodesicInverse(q.intersection, n[1]).dist ? n[0] : n[1]);
  182.                     trueLine(p[0], p[1], '#0f0');
  183.                     trueLine(p[1], p[2], '#0f0');
  184.                     trueLine(p[2], p[0], '#0f0');
  185.                     o = triCen(p[0], p[1], p[2], '#f00', true)
  186.                 }
  187.             }
  188.         }
  189.         if (o) {
  190.             console.log(o.lat+" "+o.lng);
  191.          // j.push(s_snijpunt, '<b>' + formatCoords(o) + '</b>');
  192.             // createMarker(o, s_snijpunt_letter);
  193.             // resMarker[resMarker.length - 1].geom.setZIndexOffset(1000)
  194.         } else {
  195.           // j.push(s_snijpunt_fout)
  196.         }
  197.     }
  198.    // showResult(j);
  199.     if (a) {
  200.      // zoomAll()
  201.     }
  202. }
  203.  
  204.  
  205.  
  206. function trueCircle(a, b, c, h, f) {
  207.     var d = [], i, j;
  208.     if (!h) {
  209.         h = 0;
  210.         i = true
  211.     }
  212.     var l = 360;
  213.     if (f) {
  214.         if (f < 0) {
  215.             l = h;
  216.             h += f
  217.         } else {
  218.             l = h + f
  219.         }
  220.         if (h > 540 || l > 540) {
  221.             l = l % 360;
  222.             h = h % 360
  223.         }
  224.     }
  225.     var k;
  226.     for (var n = h; n <= l; n += 0.5) {
  227.         k = GeodesicDirect(a, n, b);
  228.         if (j && (Math.abs(k.lng - j) > 180)) {
  229.             i = false;
  230.             if (d.length) {
  231.                 resGeom.push(L.polyline(d, {
  232.                     color: c,
  233.                     weight: linewidth,
  234.                     opacity: 1,
  235.                     clickable: false
  236.                 }).addTo(map))
  237.             }
  238.             d = []
  239.         }
  240.         d.push([k.lat, k.lng]);
  241.         j = k.lng
  242.     }
  243.     if (i) {
  244.         if (d.length) {
  245.             /*
  246.              * resGeom.push(L.polygon(d, { color: c, weight: linewidth, opacity: 1, clickable: false }).addTo(map))
  247.              */
  248.         }
  249.     } else {
  250.         if (d.length) {
  251.             /*
  252.              * resGeom.push(L.polyline(d, { color: c, weight: linewidth, opacity: 1, clickable: false }).addTo(map))
  253.              */
  254.         }
  255.     }
  256. }
  257.  
  258.  
  259. function GeodesicInverse(a, b) {
  260.     var c = geod.Inverse(a.lat, a.lng, b.lat, b.lng);
  261.     if (c.azi1 < 0) {
  262.         c.azi1 += 360
  263.     }
  264.     if (c.azi2 < 0) {
  265.         c.azi2 += 360
  266.     }
  267.     return {
  268.         'startbrng': c.azi1,
  269.         'endbrng': c.azi2,
  270.         'dist': c.s12
  271.     }
  272. }
  273.  
  274. function toXyz(a) {
  275.     var b = a.lat * Math.PI / 180;
  276.     var c = a.lng * Math.PI / 180;
  277.     var h = 6371009 * Math.cos(c) * Math.cos(b);
  278.     var f = 6371009 * Math.sin(c) * Math.cos(b);
  279.     var d = 6371009 * Math.sin(b);
  280.     return ({
  281.         'x': h,
  282.         'y': f,
  283.         'z': d
  284.     })
  285. }
  286. function AzimuthalEquidistantForward(a, b, c, h) {
  287.     var f = geod.Inverse(a, b, c, h);
  288.     f.azi1 *= GeographicLib.Math.degree;
  289.     return {
  290.         'x': f.s12 * Math.sin(f.azi1),
  291.         'y': f.s12 * Math.cos(f.azi1)
  292.     }
  293. }
  294. function AzimuthalEquidistantReverse(a, b, c, h) {
  295.     var f = Math.atan2(c, h) / GeographicLib.Math.degree;
  296.     var d = GeographicLib.Math.hypot(c, h);
  297.     var i = geod.Direct(a, b, f, d);
  298.     return {
  299.         'lat': i.lat2,
  300.         'lng': i.lon2
  301.     }
  302. }
  303. function trueLine(a, b, c) {
  304.     var h = geod.InversePath(a.lat, a.lng, b.lat, b.lng, 5, 1000);
  305.     var f = [];
  306.     for (var d = 0; d < h.length; d++) {
  307.         if (d && (Math.abs(h[d].lon - h[d - 1].lon) > 180)) {
  308.             if (f.length) {
  309.                 resGeom.push(L.polyline(f, {
  310.                     color: c,
  311.                     weight: linewidth,
  312.                     opacity: 1,
  313.                     clickable: false
  314.                 }).addTo(map))
  315.             }
  316.             f = []
  317.         }
  318.       // f.push(L.latLng(h[d].lat, h[d].lon))
  319.     }
  320.     if (f.length) {
  321.         /*
  322.          * resGeom.push(L.polyline(f, { color: c, weight: linewidth, opacity: 1, clickable: false }).addTo(map))
  323.          */
  324.     }
  325. }
  326. function triCen(a, b, c, h, f) {
  327.     var d = antiClockwiseOrder([a, b, c]);
  328.     var i = midPoint(d[0], d[1]);
  329.     var j = midPoint(d[1], d[2]);
  330.     var l = midPoint(d[2], d[0]);
  331.     var k = GeoIntersect([d[0], j, d[1], l]);
  332.     if (k) {
  333.         k = k.intersection
  334.     }
  335.     if (!trialt) {
  336.         trueLine(d[0], j, h);
  337.         trueLine(d[1], l, h);
  338.         trueLine(d[2], i, h)
  339.     }
  340.     if (f) {
  341.         return k
  342.     }
  343.     var n, m, o;
  344.     var q = GeoIntersect([i, j], [i.endbrng - 90, j.endbrng - 90]);
  345.     if (q) {
  346.         var p = GeodesicInverse(i, q);
  347.         var r = GeodesicInverse(j, q);
  348.         var s = GeodesicInverse(l, q);
  349.         n = GeodesicInverse(d[0], q).dist;
  350.         if (trialt) {
  351.             trueLineDirect(i, p.startbrng, p.dist, '#0f0', true);
  352.             trueLineDirect(j, r.startbrng, r.dist, '#0f0', true);
  353.             trueLineDirect(l, s.startbrng, s.dist, '#0f0', true);
  354.             trueCircle(q, n, '#0f0', 1, 360)
  355.         }
  356.     }
  357.     var t = GeoIntersect([d[0], d[2]], [(GeodesicInverse(d[0], d[2]).startbrng + i.startbrng) / 2, (GeodesicInverse(d[2], d[1]).startbrng + l.startbrng) / 2]);
  358.     if (t) {
  359.         var w = GeodesicInverse(d[0], t);
  360.         var z = GeodesicInverse(d[1], t);
  361.         var v = GeodesicInverse(d[2], t);
  362.         var u = GeoIntersept(d[0], d[1], t);
  363.         if (u) {
  364.             m = GeodesicInverse(t, u.projected).dist;
  365.             if (trialt) {
  366.                 trueLineDirect(d[0], w.startbrng, w.dist, '#ff0', true);
  367.                 trueLineDirect(d[1], z.startbrng, z.dist, '#ff0', true);
  368.                 trueLineDirect(d[2], v.startbrng, v.dist, '#ff0', true);
  369.                 trueCircle(t, m, '#ff0', 1, 360)
  370.             }
  371.         }
  372.     }
  373.     var A = GeoIntersept(d[0], d[1], d[2]);
  374.     var B = GeoIntersept(d[0], d[2], d[1]);
  375.     var C = GeoIntersept(d[1], d[2], d[0]);
  376.     if (A && B && C) {
  377.         A = A.projected;
  378.         B = B.projected;
  379.         C = C.projected;
  380.         o = GeoIntersect([d[0], C, d[1], B]);
  381.         if (o) {
  382.             o = o.intersection;
  383.             if (trialt) {
  384.                 trueLine(d[0], C, '#0ff');
  385.                 trueLine(d[1], B, '#0ff');
  386.                 trueLine(d[2], A, '#0ff');
  387.                 trueLine(C, o, '#0ff');
  388.                 trueLine(B, o, '#0ff');
  389.                 trueLine(A, o, '#0ff')
  390.             }
  391.         }
  392.     }
  393.     var D = GeodesicArea([d[0], d[1], d[2]]);
  394.     return {
  395.         'gravcen': k,
  396.         'circen': q,
  397.         'incen': t,
  398.         'orthcen': o,
  399.         'area': D.area,
  400.         'perimeter': D.perimeter,
  401.         'incenRadius': m,
  402.         'circenRadius': n
  403.     }
  404. }
  405. function antiClockwiseOrder(d) {
  406.     var i, j, l, k = [], n = [];
  407.     if (d.length == 3) {
  408.         j = (d[0].lat + d[1].lat + d[2].lat) / 3;
  409.         l = midLng(midLng(d[0].lng, d[1].lng), d[2].lng)
  410.     } else if (d.length == 4) {
  411.         var m = GeoIntersect([d[0], d[1], d[2], d[3]]);
  412.         if (!m || m.virtual) {
  413.             m = GeoIntersect([d[0], d[2], d[1], d[3]])
  414.         }
  415.         if (!m || m.virtual) {
  416.             m = GeoIntersect([d[0], d[3], d[1], d[2]])
  417.         }
  418.         if (!m || m.virtual) {
  419.             j = (d[0].lat + d[1].lat + d[2].lat + d[3].lat) / 4;
  420.             l = midLng(midLng(d[0].lng, d[1].lng), midLng(d[2].lng, d[3].lng))
  421.         }
  422.         j = m.intersection.lat;
  423.         l = m.intersection.lng
  424.     }
  425.     for (i = 0; i < d.length; i++) {
  426.         k.push(GnomonicForward(j, l, d[i].lat, d[i].lng));
  427.         if (!k[k.length - 1]) {
  428.             return null
  429.         }
  430.     }
  431.     k.sort(function(a, b) {
  432.         if (a.x >= 0 && b.x < 0) {
  433.             return 1
  434.         }
  435.         if (a.x < 0 && b.x >= 0) {
  436.             return -1
  437.         }
  438.         if (a.x === 0 && b.x === 0) {
  439.             if (a.y >= 0 || b.y >= 0) {
  440.                 return a.y > b.y ? 1 : -1
  441.             }
  442.             return b.y > a.y ? 1 : -1
  443.         }
  444.         var c = a.x * b.y - b.x * a.y;
  445.         if (c < 0) {
  446.             return 1
  447.         }
  448.         if (c > 0) {
  449.             return -1
  450.         }
  451.         var h = a.x * a.x + a.y * a.y;
  452.         var f = b.x * b.x + b.y * b.y;
  453.         return h > f ? 1 : -1
  454.     });
  455.     for (i = 0; i < d.length; i++) {
  456.         n.push(GnomonicReverse(j, l, k[i].x, k[i].y))
  457.     }
  458.     return n
  459. }
  460. function midLng(a, b) {
  461.     a = a * Math.PI / 180;
  462.     b = b * Math.PI / 180;
  463.     var c = a + Math.atan2(Math.sin(b - a), 1 + Math.cos(b - a));
  464.     c = (c + 3 * Math.PI) % (2 * Math.PI) - Math.PI;
  465.     return c * 180 / Math.PI
  466. }
  467. function GnomonicForward(a, b, c, h) {
  468.     var f = GeographicLib.Geodesic;
  469.     var d = geod.GenInverse(a, b, c, h, f.AZIMUTH | f.REDUCEDLENGTH | f.GEODESICSCALE);
  470.     if (d.M12 <= 0) {
  471.         return null
  472.     }
  473.     var i = d.m12 / d.M12;
  474.     d.azi1 *= GeographicLib.Math.degree;
  475.     var j = i * Math.sin(d.azi1);
  476.     var l = i * Math.cos(d.azi1);
  477.     return {
  478.         'x': j,
  479.         'y': l
  480.     }
  481. }
  482. function GnomonicReverse(a, b, c, h) {
  483.     var f = 10, d = 0, i, j;
  484.     var l = 0.01 * Math.sqrt(GeographicLib.Math.epsilon);
  485.     var k = Math.atan2(c, h) / GeographicLib.Math.degree;
  486.     var n = GeographicLib.Math.hypot(c, h);
  487.     var m = 6378137 * Math.atan(n / 6378137);
  488.     var o = n <= 6378137;
  489.     if (!o) {
  490.         n = 1 / n
  491.     }
  492.     var q = new GeographicLib.GeodesicLine.GeodesicLine(geod,a,b,k,g.LATITUDE | g.LONGITUDE | g.AZIMUTH | g.DISTANCE_IN | g.REDUCEDLENGTH | g.GEODESICSCALE);
  493.     while (f--) {
  494.         j = q.GenPosition(false, m, g.LATITUDE | g.LONGITUDE | g.AZIMUTH | g.REDUCEDLENGTH | g.GEODESICSCALE);
  495.         if (d) {
  496.             break
  497.         }
  498.         i = o ? (j.m12 / j.M12 - n) * j.M12 * j.M12 : (n - j.M12 / j.m12) * j.m12 * j.m12;
  499.         m -= i;
  500.         if (Math.abs(i) < l * 6378137) {
  501.             d++
  502.         }
  503.     }
  504.     if (d) {
  505.         return {
  506.             'lat': j.lat2,
  507.             'lng': j.lon2
  508.         }
  509.     }
  510.     return null
  511. }
  512. function midPoint(a, b) {
  513.     var c = GeodesicInverse(a, b);
  514.     return GeodesicDirect(a, c.startbrng, c.dist / 2)
  515. }
  516. function GeoIntersect(a, b, c) {
  517.     var h = a[0], f, d, i;
  518.     if (a.length == 2) {
  519.         d = a[1];
  520.         f = GeodesicDirect(h, b[0], 500000);
  521.         i = GeodesicDirect(d, b[1], 500000)
  522.     } else {
  523.         f = a[1];
  524.         d = a[2];
  525.         i = a[3]
  526.     }
  527.     var j = GnomonicSolveIntersect(h, f, d, i);
  528.     if (!j || !isFinite(j.lat) || !isFinite(j.lng)) {
  529.         return null
  530.     }
  531.     var l = GeodesicInverse(h, j);
  532.     var k = GeodesicInverse(d, j);
  533.     if (b) {
  534.         if (c && (Math.abs(b[0] - l.startbrng) > 0.1 || Math.abs(b[1] - k.startbrng) > 0.1)) {
  535.             h = GeodesicDirect(a[0], b[0], 19000000);
  536.             d = GeodesicDirect(a[1], b[1], 19000000);
  537.             f = GeodesicDirect(a[0], b[0], 20000000);
  538.             i = GeodesicDirect(a[1], b[1], 20000000);
  539.             j = GnomonicSolveIntersect(h, f, d, i);
  540.             if (!j || !isFinite(j.lat) || !isFinite(j.lng)) {
  541.                 return null
  542.             }
  543.         }
  544.         return j
  545.     } else {
  546.         var n = GeodesicInverse(f, j);
  547.         var m = GeodesicInverse(h, f);
  548.         var o = GeodesicInverse(i, j);
  549.         var q = GeodesicInverse(d, i);
  550.         var p, r, s;
  551.         if (l.dist > m.dist || n.dist > m.dist) {
  552.             p = true;
  553.             r = l.dist < n.dist ? h : f
  554.         }
  555.         if (k.dist > q.dist || o.dist > q.dist) {
  556.             p = true;
  557.             s = k.dist < o.dist ? d : i
  558.         }
  559.         return {
  560.             'intersection': j,
  561.             'virtual': p,
  562.             'extA': r,
  563.             'extB': s
  564.         }
  565.     }
  566. }
  567. function GnomonicSolveIntersect(a, b, c, h) {
  568.     var f, d, i, j, l, k, n, m, o, q, p, r, s;
  569.     var t = (a.lat + b.lat + c.lat + h.lat) / 4;
  570.     var w = midLng(midLng(a.lng, b.lng), midLng(c.lng, h.lng));
  571.     for (s = 0; s < 10; s++) {
  572.         f = GnomonicForward(t, w, a.lat, a.lng);
  573.         d = GnomonicForward(t, w, b.lat, b.lng);
  574.         i = GnomonicForward(t, w, c.lat, c.lng);
  575.         j = GnomonicForward(t, w, h.lat, h.lng);
  576.         if (!f || !d || !i || !j) {
  577.             return null
  578.         }
  579.         l = {
  580.             'x': f.x,
  581.             'y': f.y,
  582.             'z': 1
  583.         };
  584.         k = {
  585.             'x': d.x,
  586.             'y': d.y,
  587.             'z': 1
  588.         };
  589.         n = {
  590.             'x': i.x,
  591.             'y': i.y,
  592.             'z': 1
  593.         };
  594.         m = {
  595.             'x': j.x,
  596.             'y': j.y,
  597.             'z': 1
  598.         };
  599.         o = vectorCross(l, k, false);
  600.         q = vectorCross(n, m, false);
  601.         p = vectorCross(o, q, true);
  602.         r = GnomonicReverse(t, w, p.x, p.y);
  603.         if (!r) {
  604.             return null
  605.         }
  606.         t = r.lat;
  607.         w = r.lng
  608.     }
  609.     return {
  610.         'lat': t,
  611.         'lng': w
  612.     }
  613. }
  614. function vectorCross(a, b, c) {
  615.     var h = a.y * b.z - a.z * b.y;
  616.     var f = a.z * b.x - a.x * b.z;
  617.     var d = a.x * b.y - a.y * b.x;
  618.     if (c) {
  619.         h /= d;
  620.         f /= d;
  621.         d = 1
  622.     }
  623.     return {
  624.         'x': h,
  625.         'y': f,
  626.         'z': d
  627.     }
  628. }
  629. function intersectCirclesEAP(a, b, c, h) {
  630.     var f = c.x - a.x;
  631.     var d = c.y - a.y;
  632.     var i = Math.sqrt(f * f + d * d);
  633.     var j = (i * i + b * b - h * h) / (2 * i);
  634.     var l = Math.sqrt(b * b - j * j);
  635.     var k = a.x + f * j / i + (d / i) * l;
  636.     var n = a.y + d * j / i - (f / i) * l;
  637.     var m = a.x + f * j / i - (d / i) * l;
  638.     var o = a.y + d * j / i + (f / i) * l;
  639.     if (Math.sqrt(k * k + n * n) < Math.sqrt(m * m + o * o)) {
  640.         return {
  641.             'x': k,
  642.             'y': n
  643.         }
  644.     }
  645.     return {
  646.         'x': m,
  647.         'y': o
  648.     }
  649. }
  650.  
  651. var GeographicLib;if(!GeographicLib)GeographicLib={};
  652. GeographicLib.Math={};
  653. GeographicLib.Math.sq=function(x){return x*x;}
  654. GeographicLib.Math.hypot=function(x,y){x=Math.abs(x);y=Math.abs(y);var a=Math.max(x,y),b=Math.min(x,y)/(a?a:1);return a*Math.sqrt(1+b*b);}
  655. GeographicLib.Math.cbrt=function(x){var y=Math.pow(Math.abs(x),1/3);return x<0?-y:y;}
  656. GeographicLib.Math.log1p=function(x){var y=1+x,z=y-1;return z==0?x:x*Math.log(y)/z;}
  657. GeographicLib.Math.atanh=function(x){var y=Math.abs(x);y=GeographicLib.Math.log1p(2*y/(1-y))/2;return x<0?-y:y;}
  658. GeographicLib.Math.sum=function(u,v){var s=u+v,up=s-v,vpp=s-up;up-=u;vpp-=v;t=-(up+vpp);return{s:s,t:t};}
  659. GeographicLib.Math.AngNormalize=function(x){return x>=180?x-360:(x<-180?x+360:x);}
  660. GeographicLib.Math.AngNormalize2=function(x){return GeographicLib.Math.AngNormalize(x%360);}
  661. GeographicLib.Math.AngDiff=function(x,y){var d=y-x,yp=d+x,xpp=yp-d;yp-=y;xpp-=x;var t=xpp-yp;if((d-180)+t>0){d-=360}else if((d+180)+t<=0){d+=360}return d+t;}
  662. GeographicLib.Math.epsilon=Math.pow(0.5,52);GeographicLib.Math.degree=Math.PI/180;GeographicLib.Math.digits=53;GeographicLib.Constants={};GeographicLib.Constants.WGS84={a:6378137,f:1/298.257223563};
  663. GeographicLib.Accumulator={};
  664. (function(){
  665. a=GeographicLib.Accumulator;var m=GeographicLib.Math;a.Accumulator=function(y){this.Set(y)}
  666. a.Accumulator.prototype.Set=function(y){if(!y)y=0;if(y.constructor==a.Accumulator){this._s=y._s;this._t=y._t;}else{this._s=y;this._t=0;}}
  667. a.Accumulator.prototype.Add=function(y){var u=m.sum(y,this._t);var v=m.sum(u.s,this._s);u=u.t;this._s=v.s;this._t=v.t;if(this._s==0){this._s=u;}else{this._t+=u;}}
  668. a.Accumulator.prototype.Sum=function(y){if(!y){return this._s;}else{var b=new a.Accumulator(this);b.Add(y);return b._s;}}
  669. a.Accumulator.prototype.Negate=function(){this._s*=-1;this._t*=-1;}
  670. })();
  671. GeographicLib.Geodesic={};GeographicLib.GeodesicLine={};
  672. (function(){
  673. var m=GeographicLib.Math;var g=GeographicLib.Geodesic;var l=GeographicLib.GeodesicLine;g.GEOGRAPHICLIB_GEODESIC_ORDER=6;g.nA1_=g.GEOGRAPHICLIB_GEODESIC_ORDER;g.nC1_=g.GEOGRAPHICLIB_GEODESIC_ORDER;g.nC1p_=g.GEOGRAPHICLIB_GEODESIC_ORDER;g.nA2_=g.GEOGRAPHICLIB_GEODESIC_ORDER;g.nC2_=g.GEOGRAPHICLIB_GEODESIC_ORDER;g.nA3_=g.GEOGRAPHICLIB_GEODESIC_ORDER;g.nA3x_=g.nA3_;g.nC3_=g.GEOGRAPHICLIB_GEODESIC_ORDER;g.nC3x_=(g.nC3_*(g.nC3_-1))/2;g.nC4_=g.GEOGRAPHICLIB_GEODESIC_ORDER;g.nC4x_=(g.nC4_*(g.nC4_+1))/2;g.maxit1_=20;g.maxit2_=g.maxit1_+m.digits+10;g.tiny_=Math.sqrt(Number.MIN_VALUE);g.tol0_=m.epsilon;g.tol1_=200*g.tol0_;g.tol2_=Math.sqrt(g.tol0_);g.tolb_=g.tol0_*g.tol1_;g.xthresh_=1000*g.tol2_;g.CAP_NONE=0;g.CAP_C1=1<<0;g.CAP_C1p=1<<1;g.CAP_C2=1<<2;g.CAP_C3=1<<3;g.CAP_C4=1<<4;g.CAP_ALL=0x1F;g.OUT_ALL=0x7F80;g.NONE=0;g.LATITUDE=1<<7|g.CAP_NONE;g.LONGITUDE=1<<8|g.CAP_C3;g.AZIMUTH=1<<9|g.CAP_NONE;g.DISTANCE=1<<10|g.CAP_C1;g.DISTANCE_IN=1<<11|g.CAP_C1|g.CAP_C1p;g.REDUCEDLENGTH=1<<12|g.CAP_C1|g.CAP_C2;g.GEODESICSCALE=1<<13|g.CAP_C1|g.CAP_C2;g.AREA=1<<14|g.CAP_C4;g.ALL=g.OUT_ALL|g.CAP_ALL;
  674. g.SinCosSeries=function(sinp,sinx,cosx,c,n){var k=n+(sinp?1:0);var ar=2*(cosx-sinx)*(cosx+sinx),y0=n&1?c[--k]:0,y1=0;n=Math.floor(n/2);while(n--){y1=ar*y0-y1+c[--k];y0=ar*y1-y0+c[--k];}return(sinp
  675. ?2*sinx*cosx*y0:cosx*(y0-y1));}
  676. g.AngRound=function(x){var z=1/16;var y=Math.abs(x);y=y<z?z-(z-y):y;return x<0?-y:y;}
  677. g.Astroid=function(x,y){
  678. var k;var p=m.sq(x),q=m.sq(y),r=(p+q-1)/6;if(!(q==0&&r<=0)){var S=p*q/4,r2=m.sq(r),r3=r*r2,disc=S*(S+2*r3);var u=r;if(disc>=0){var T3=S+r3;T3+=T3<0?-Math.sqrt(disc):Math.sqrt(disc);var T=m.cbrt(T3);u+=T+(T!=0?r2/T:0);}else{var ang=Math.atan2(Math.sqrt(-disc),-(S+r3));u+=2*r*Math.cos(ang/3);}var v=Math.sqrt(m.sq(u)+q),uv=u<0?q/(v-u):u+v,w=(uv-q)/(2*v);k=uv/(Math.sqrt(uv+m.sq(w))+w);}else{k=0;}return k;}
  679. g.A1m1f=function(eps){var eps2=m.sq(eps),t=eps2*(eps2*(eps2+4)+64)/256;return(t+eps)/(1-eps);}
  680. g.C1f=function(eps,c){var eps2=m.sq(eps),d=eps;c[1]=d*((6-eps2)*eps2-16)/32;d*=eps;c[2]=d*((64-9*eps2)*eps2-128)/2048;d*=eps;c[3]=d*(9*eps2-16)/768;d*=eps;c[4]=d*(3*eps2-5)/512;d*=eps;c[5]=-7*d/1280;d*=eps;c[6]=-7*d/2048;}
  681. g.C1pf=function(eps,c){var eps2=m.sq(eps),d=eps;c[1]=d*(eps2*(205*eps2-432)+768)/1536;d*=eps;c[2]=d*(eps2*(4005*eps2-4736)+3840)/12288;d*=eps;c[3]=d*(116-225*eps2)/384;d*=eps;c[4]=d*(2695-7173*eps2)/7680;d*=eps;c[5]=3467*d/7680;d*=eps;c[6]=38081*d/61440;}
  682. g.A2m1f=function(eps){var eps2=m.sq(eps),t=eps2*(eps2*(25*eps2+36)+64)/256;return t*(1-eps)-eps;}
  683. g.C2f=function(eps,c){var eps2=m.sq(eps),d=eps;c[1]=d*(eps2*(eps2+2)+16)/32;d*=eps;c[2]=d*(eps2*(35*eps2+64)+384)/2048;d*=eps;c[3]=d*(15*eps2+80)/768;d*=eps;c[4]=d*(7*eps2+35)/512;d*=eps;c[5]=63*d/1280;d*=eps;c[6]=77*d/2048;}
  684. g.Geodesic=function(a,f){this._a=a;this._f=f<=1?f:1/f;this._f1=1-this._f;this._e2=this._f*(2-this._f);this._ep2=this._e2/m.sq(this._f1);this._n=this._f/(2-this._f);this._b=this._a*this._f1;this._c2=(m.sq(this._a)+m.sq(this._b)*(this._e2==0?1:(this._e2>0?m.atanh(Math.sqrt(this._e2)):Math.atan(Math.sqrt(-this._e2)))/Math.sqrt(Math.abs(this._e2))))/2;this._etol2=0.1*g.tol2_/Math.sqrt(Math.max(0.001,Math.abs(this._f))*Math.min(1.0,1-this._f/2)/2);if(!(isFinite(this._a)&&this._a>0)){throw new Error("Major radius is not positive")}if(!(isFinite(this._b)&&this._b>0)){throw new Error("Minor radius is not positive")}this._A3x=new Array(g.nA3x_);this._C3x=new Array(g.nC3x_);this._C4x=new Array(g.nC4x_);this.A3coeff();this.C3coeff();this.C4coeff();}
  685. g.Geodesic.prototype.A3coeff=function(){var _n=this._n;this._A3x[0]=1;this._A3x[1]=(_n-1)/2;this._A3x[2]=(_n*(3*_n-1)-2)/8;this._A3x[3]=((-_n-3)*_n-1)/16;this._A3x[4]=(-2*_n-3)/64;this._A3x[5]=-3/128;}
  686. g.Geodesic.prototype.C3coeff=function(){var _n=this._n;this._C3x[0]=(1-_n)/4;this._C3x[1]=(1-_n*_n)/8;this._C3x[2]=((3-_n)*_n+3)/64;this._C3x[3]=(2*_n+5)/128;this._C3x[4]=3/128;this._C3x[5]=((_n-3)*_n+2)/32;this._C3x[6]=((-3*_n-2)*_n+3)/64;this._C3x[7]=(_n+3)/128;this._C3x[8]=5/256;this._C3x[9]=(_n*(5*_n-9)+5)/192;this._C3x[10]=(9-10*_n)/384;this._C3x[11]=7/512;this._C3x[12]=(7-14*_n)/512;this._C3x[13]=7/512;this._C3x[14]=21/2560;}
  687. g.Geodesic.prototype.C4coeff=function(){var _n=this._n;this._C4x[0]=(_n*(_n*(_n*(_n*(100*_n+208)+572)+3432)-12012)+30030)/45045;this._C4x[1]=(_n*(_n*(_n*(64*_n+624)-4576)+6864)-3003)/15015;this._C4x[2]=(_n*((14144-10656*_n)*_n-4576)-858)/45045;this._C4x[3]=((-224*_n-4784)*_n+1573)/45045;this._C4x[4]=(1088*_n+156)/45045;this._C4x[5]=97/15015.0;this._C4x[6]=(_n*(_n*((-64*_n-624)*_n+4576)-6864)+3003)/135135;this._C4x[7]=(_n*(_n*(5952*_n-11648)+9152)-2574)/135135;this._C4x[8]=(_n*(5792*_n+1040)-1287)/135135;this._C4x[9]=(468-2944*_n)/135135;this._C4x[10]=1/9009.0;this._C4x[11]=(_n*((4160-1440*_n)*_n-4576)+1716)/225225;this._C4x[12]=((4992-8448*_n)*_n-1144)/225225;this._C4x[13]=(1856*_n-936)/225225;this._C4x[14]=8/10725.0;this._C4x[15]=(_n*(3584*_n-3328)+1144)/315315;this._C4x[16]=(1024*_n-208)/105105;this._C4x[17]=-136/63063.0;this._C4x[18]=(832-2560*_n)/405405;this._C4x[19]=-128/135135.0;this._C4x[20]=128/99099.0;}
  688. g.Geodesic.prototype.A3f=function(eps){var v=0;for(var i=g.nA3x_;i;){v=eps*v+this._A3x[--i]}return v;}
  689. g.Geodesic.prototype.C3f=function(eps,c){for(var j=g.nC3x_,k=g.nC3_-1;k;){var t=0;for(var i=g.nC3_-k;i;--i){t=eps*t+this._C3x[--j]}c[k--]=t}var mult=1;for(var k=1;k<g.nC3_;){mult*=eps;c[k++]*=mult;}}
  690. g.Geodesic.prototype.C4f=function(eps,c){for(var j=g.nC4x_,k=g.nC4_;k;){var t=0;for(var i=g.nC4_-k+1;i;--i){t=eps*t+this._C4x[--j]}c[--k]=t;}var mult=1;for(var k=1;k<g.nC4_;){mult*=eps;c[k++]*=mult;}}
  691. g.Geodesic.prototype.Lengths=function(eps,sig12,ssig1,csig1,dn1,ssig2,csig2,dn2,cbet1,cbet2,scalep,C1a,C2a){var vals={};g.C1f(eps,C1a);g.C2f(eps,C2a);var A1m1=g.A1m1f(eps),AB1=(1+A1m1)*(g.SinCosSeries(true,ssig2,csig2,C1a,g.nC1_)-g.SinCosSeries(true,ssig1,csig1,C1a,g.nC1_)),A2m1=g.A2m1f(eps),AB2=(1+A2m1)*(g.SinCosSeries(true,ssig2,csig2,C2a,g.nC2_)-g.SinCosSeries(true,ssig1,csig1,C2a,g.nC2_));vals.m0=A1m1-A2m1;var J12=vals.m0*sig12+(AB1-AB2);vals.m12b=dn2*(csig1*ssig2)-dn1*(ssig1*csig2)-csig1*csig2*J12;vals.s12b=(1+A1m1)*sig12+AB1;if(scalep){var csig12=csig1*csig2+ssig1*ssig2;var t=this._ep2*(cbet1-cbet2)*(cbet1+cbet2)/(dn1+dn2);vals.M12=csig12+(t*ssig2-csig2*J12)*ssig1/dn1;vals.M21=csig12-(t*ssig1-csig1*J12)*ssig2/dn2;}return vals;}
  692. g.Geodesic.prototype.InverseStart=function(sbet1,cbet1,dn1,sbet2,cbet2,dn2,lam12,C1a,C2a){
  693. var vals={},sbet12=sbet2*cbet1-cbet2*sbet1,cbet12=cbet2*cbet1+sbet2*sbet1;vals.sig12=-1;var sbet12a=sbet2*cbet1;sbet12a+=cbet2*sbet1;var shortline=cbet12>=0&&sbet12<0.5&&cbet2*lam12<0.5;var omg12=lam12;if(shortline){var sbetm2=m.sq(sbet1+sbet2);sbetm2/=sbetm2+m.sq(cbet1+cbet2);vals.dnm=Math.sqrt(1+this._ep2*sbetm2);omg12/=this._f1*vals.dnm;}var somg12=Math.sin(omg12),comg12=Math.cos(omg12);vals.salp1=cbet2*somg12;vals.calp1=comg12>=0?sbet12+cbet2*sbet1*m.sq(somg12)/(1+comg12):sbet12a-cbet2*sbet1*m.sq(somg12)/(1-comg12);var ssig12=m.hypot(vals.salp1,vals.calp1),csig12=sbet1*sbet2+cbet1*cbet2*comg12;if(shortline&&ssig12<this._etol2){vals.salp2=cbet1*somg12;vals.calp2=sbet12-cbet1*sbet2*(comg12>=0?m.sq(somg12)/(1+comg12):1-comg12);var t=m.hypot(vals.salp2,vals.calp2);vals.salp2/=t;vals.calp2/=t;vals.sig12=Math.atan2(ssig12,csig12);}else if(Math.abs(this._n)>0.1||csig12>=0||ssig12>=6*Math.abs(this._n)*Math.PI*m.sq(cbet1)){}else{var y,lamscale,betscale;var x;if(this._f>=0){{var k2=m.sq(sbet1)*this._ep2,eps=k2/(2*(1+Math.sqrt(1+k2))+k2);lamscale=this._f*cbet1*this.A3f(eps)*Math.PI;}betscale=lamscale*cbet1;x=(lam12-Math.PI)/lamscale;y=sbet12a/betscale;}else{var cbet12a=cbet2*cbet1-sbet2*sbet1,bet12a=Math.atan2(sbet12a,cbet12a);var m12b,m0;var nvals=this.Lengths(this._n,Math.PI+bet12a,sbet1,-cbet1,dn1,sbet2,cbet2,dn2,cbet1,cbet2,false,C1a,C2a);m12b=nvals.m12b;m0=nvals.m0;x=-1+m12b/(cbet1*cbet2*m0*Math.PI);betscale=x<-0.01?sbet12a/x:-this._f*m.sq(cbet1)*Math.PI;lamscale=betscale/cbet1;y=(lam12-Math.PI)/lamscale;}if(y>-g.tol1_&&x>-1-g.xthresh_){if(this._f>=0){vals.salp1=Math.min(1,-x);vals.calp1=-Math.sqrt(1-m.sq(vals.salp1));}else{vals.calp1=Math.max(x>-g.tol1_?0:-1,x);vals.salp1=Math.sqrt(1-m.sq(vals.calp1));}}else{var k=g.Astroid(x,y);var omg12a=lamscale*(this._f>=0?-x*k/(1+k):-y*(1+k)/k);somg12=Math.sin(omg12a);comg12=-Math.cos(omg12a);vals.salp1=cbet2*somg12;vals.calp1=sbet12a-cbet2*sbet1*m.sq(somg12)/(1-comg12);}}if(vals.salp1>0){var t=m.hypot(vals.salp1,vals.calp1);vals.salp1/=t;vals.calp1/=t;}else{vals.salp1=1;vals.calp1=0;}return vals;}
  694. g.Geodesic.prototype.Lambda12=function(sbet1,cbet1,dn1,sbet2,cbet2,dn2,salp1,calp1,diffp,C1a,C2a,C3a){
  695. var vals={};if(sbet1==0&&calp1==0){calp1=-g.tiny_}var salp0=salp1*cbet1,calp0=m.hypot(calp1,salp1*sbet1);var somg1,comg1,somg2,comg2,omg12;vals.ssig1=sbet1;somg1=salp0*sbet1;vals.csig1=comg1=calp1*cbet1;var t=m.hypot(vals.ssig1,vals.csig1);vals.ssig1/=t;vals.csig1/=t;vals.salp2=cbet2!=cbet1?salp0/cbet2:salp1;vals.calp2=cbet2!=cbet1||Math.abs(sbet2)!=-sbet1?Math.sqrt(m.sq(calp1*cbet1)+(cbet1<-sbet1?(cbet2-cbet1)*(cbet1+cbet2):(sbet1-sbet2)*(sbet1+sbet2)))/cbet2:Math.abs(calp1);vals.ssig2=sbet2;somg2=salp0*sbet2;vals.csig2=comg2=vals.calp2*cbet2;var t=m.hypot(vals.ssig2,vals.csig2);vals.ssig2/=t;vals.csig2/=t;vals.sig12=Math.atan2(Math.max(vals.csig1*vals.ssig2-vals.ssig1*vals.csig2,0),vals.csig1*vals.csig2+vals.ssig1*vals.ssig2);omg12=Math.atan2(Math.max(comg1*somg2-somg1*comg2,0),comg1*comg2+somg1*somg2);var B312,h0;var k2=m.sq(calp0)*this._ep2;vals.eps=k2/(2*(1+Math.sqrt(1+k2))+k2);this.C3f(vals.eps,C3a);B312=(g.SinCosSeries(true,vals.ssig2,vals.csig2,C3a,g.nC3_-1)-g.SinCosSeries(true,vals.ssig1,vals.csig1,C3a,g.nC3_-1));h0=-this._f*this.A3f(vals.eps);vals.domg12=salp0*h0*(vals.sig12+B312);vals.lam12=omg12+vals.domg12;if(diffp){if(vals.calp2==0){vals.dlam12=-2*this._f1*dn1/sbet1}else{var nvals=this.Lengths(vals.eps,vals.sig12,vals.ssig1,vals.csig1,dn1,vals.ssig2,vals.csig2,dn2,cbet1,cbet2,false,C1a,C2a);vals.dlam12=nvals.m12b;vals.dlam12*=this._f1/(vals.calp2*cbet2);}}return vals;}
  696. g.Geodesic.prototype.GenInverse=function(lat1,lon1,lat2,lon2,outmask){var vals={};outmask&=g.OUT_ALL;var lon12=m.AngDiff(m.AngNormalize(lon1),m.AngNormalize(lon2));lon12=g.AngRound(lon12);var lonsign=lon12>=0?1:-1;lon12*=lonsign;lat1=g.AngRound(lat1);lat2=g.AngRound(lat2);var swapp=Math.abs(lat1)>=Math.abs(lat2)?1:-1;if(swapp<0){lonsign*=-1;var t=lat1;lat1=lat2;lat2=t;}var latsign=lat1<0?1:-1;lat1*=latsign;lat2*=latsign;var phi,sbet1,cbet1,sbet2,cbet2,s12x,m12x;phi=lat1*m.degree;sbet1=this._f1*Math.sin(phi);cbet1=lat1==-90?g.tiny_:Math.cos(phi);var t=m.hypot(sbet1,cbet1);sbet1/=t;cbet1/=t;phi=lat2*m.degree;sbet2=this._f1*Math.sin(phi);cbet2=Math.abs(lat2)==90?g.tiny_:Math.cos(phi);var t=m.hypot(sbet2,cbet2);sbet2/=t;cbet2/=t;if(cbet1<-sbet1){if(cbet2==cbet1){sbet2=sbet2<0?sbet1:-sbet1;}}else{if(Math.abs(sbet2)==-sbet1){cbet2=cbet1;}}var dn1=Math.sqrt(1+this._ep2*m.sq(sbet1)),dn2=Math.sqrt(1+this._ep2*m.sq(sbet2));var lam12=lon12*m.degree,slam12=lon12==180?0:Math.sin(lam12),clam12=Math.cos(lam12);var sig12,calp1,salp1,calp2,salp2;var C1a=new Array(g.nC1_+1),C2a=new Array(g.nC2_+1),C3a=new Array(g.nC3_);var meridian=lat1==-90||slam12==0;if(meridian){calp1=clam12;salp1=slam12;calp2=1;salp2=0;var ssig1=sbet1,csig1=calp1*cbet1,ssig2=sbet2,csig2=calp2*cbet2;sig12=Math.atan2(Math.max(csig1*ssig2-ssig1*csig2,0),csig1*csig2+ssig1*ssig2);{var nvals=this.Lengths(this._n,sig12,ssig1,csig1,dn1,ssig2,csig2,dn2,cbet1,cbet2,(outmask&g.GEODESICSCALE)!=0,C1a,C2a);s12x=nvals.s12b;m12x=nvals.m12b;if((outmask&g.GEODESICSCALE)!=0){vals.M12=nvals.M12;vals.M21=nvals.M21;}}if(sig12<1||m12x>=0){m12x*=this._b;s12x*=this._b;vals.a12=sig12/m.degree;}else{meridian=false}}var omg12;if(!meridian&&sbet1==0&&(this._f<=0||lam12<=Math.PI-this._f*Math.PI)){calp1=calp2=0;salp1=salp2=1;s12x=this._a*lam12;sig12=omg12=lam12/this._f1;m12x=this._b*Math.sin(sig12);if(outmask&g.GEODESICSCALE){vals.M12=vals.M21=Math.cos(sig12)}vals.a12=lon12/this._f1;}else if(!meridian){var nvals=this.InverseStart(sbet1,cbet1,dn1,sbet2,cbet2,dn2,lam12,C1a,C2a);sig12=nvals.sig12;salp1=nvals.salp1;calp1=nvals.calp1;if(sig12>=0){salp2=nvals.salp2;calp2=nvals.calp2;var dnm=nvals.dnm;s12x=sig12*this._b*dnm;m12x=m.sq(dnm)*this._b*Math.sin(sig12/dnm);if(outmask&g.GEODESICSCALE){vals.M12=vals.M21=Math.cos(sig12/dnm)}vals.a12=sig12/m.degree;omg12=lam12/(this._f1*dnm);}else{var ssig1,csig1,ssig2,csig2,eps;var numit=0;var salp1a=g.tiny_,calp1a=1,salp1b=g.tiny_,calp1b=-1;for(var tripn=false,tripb=false;numit<g.maxit2_;++numit){var dv;var nvals=this.Lambda12(sbet1,cbet1,dn1,sbet2,cbet2,dn2,salp1,calp1,numit<g.maxit1_,
  697. C1a,C2a,C3a);var v=nvals.lam12-lam12;salp2=nvals.salp2;calp2=nvals.calp2;sig12=nvals.sig12;ssig1=nvals.ssig1;csig1=nvals.csig1;ssig2=nvals.ssig2;csig2=nvals.csig2;eps=nvals.eps;omg12=nvals.domg12;dv=nvals.dlam12;if(tripb||!(Math.abs(v)>=(tripn?8:2)*g.tol0_)){break}if(v>0&&(numit<g.maxit1_||calp1/salp1>calp1b/salp1b)){salp1b=salp1;calp1b=calp1;}else if(v<0&&(numit<g.maxit1_||calp1/salp1<calp1a/salp1a)){salp1a=salp1;calp1a=calp1;}if(numit<g.maxit1_&&dv>0){var dalp1=-v/dv;var sdalp1=Math.sin(dalp1),cdalp1=Math.cos(dalp1),nsalp1=salp1*cdalp1+calp1*sdalp1;if(nsalp1>0&&Math.abs(dalp1)<Math.PI){calp1=calp1*cdalp1-salp1*sdalp1;salp1=Math.max(0,nsalp1);var t=m.hypot(salp1,calp1);salp1/=t;calp1/=t;tripn=Math.abs(v)<=16*g.tol0_;continue;}}salp1=(salp1a+salp1b)/2;calp1=(calp1a+calp1b)/2;var t=m.hypot(salp1,calp1);salp1/=t;calp1/=t;tripn=false;tripb=(Math.abs(salp1a-salp1)+(calp1a-calp1)<g.tolb_||Math.abs(salp1-salp1b)+(calp1-calp1b)<g.tolb_);}{var nvals=this.Lengths(eps,sig12,ssig1,csig1,dn1,ssig2,csig2,dn2,cbet1,cbet2,(outmask&g.GEODESICSCALE)!=0,C1a,C2a);s12x=nvals.s12b;m12x=nvals.m12b;if((outmask&g.GEODESICSCALE)!=0){vals.M12=nvals.M12;vals.M21=nvals.M21;}}m12x*=this._b;s12x*=this._b;vals.a12=sig12/m.degree;omg12=lam12-omg12;}}if(outmask&g.DISTANCE){vals.s12=0+s12x}if(outmask&g.REDUCEDLENGTH){vals.m12=0+m12x}if(outmask&g.AREA){var salp0=salp1*cbet1,calp0=m.hypot(calp1,salp1*sbet1);var alp12;if(calp0!=0&&salp0!=0){var ssig1=sbet1,csig1=calp1*cbet1,ssig2=sbet2,csig2=calp2*cbet2,k2=m.sq(calp0)*this._ep2,eps=k2/(2*(1+Math.sqrt(1+k2))+k2);A4=m.sq(this._a)*calp0*salp0*this._e2;var t=m.hypot(ssig1,csig1);ssig1/=t;csig1/=t;var t=m.hypot(ssig2,csig2);ssig2/=t;csig2/=t;var C4a=new Array(g.nC4_);this.C4f(eps,C4a);var B41=g.SinCosSeries(false,ssig1,csig1,C4a,g.nC4_),B42=g.SinCosSeries(false,ssig2,csig2,C4a,g.nC4_);vals.S12=A4*(B42-B41);}else{vals.S12=0}if(!meridian&&omg12<0.75*Math.PI&&sbet2-sbet1<1.75){var somg12=Math.sin(omg12),domg12=1+Math.cos(omg12),dbet1=1+cbet1,dbet2=1+cbet2;alp12=2*Math.atan2(somg12*(sbet1*dbet2+sbet2*dbet1),domg12*(sbet1*sbet2+dbet1*dbet2));}else{var salp12=salp2*calp1-calp2*salp1,calp12=calp2*calp1+salp2*salp1;if(salp12==0&&calp12<0){salp12=g.tiny_*calp1;calp12=-1;}alp12=Math.atan2(salp12,calp12);}vals.S12+=this._c2*alp12;vals.S12*=swapp*lonsign*latsign;vals.S12+=0;}if(swapp<0){var t=salp1;salp1=salp2;salp2=t;var t=calp1;calp1=calp2;calp2=t;if(outmask&g.GEODESICSCALE){var t=vals.M12;vals.M12=vals.M21;vals.M21=t;}}salp1*=swapp*lonsign;calp1*=swapp*latsign;salp2*=swapp*lonsign;calp2*=swapp*latsign;if(outmask&g.AZIMUTH){vals.azi1=0-Math.atan2(-salp1,calp1)/m.degree;vals.azi2=0-Math.atan2(-salp2,calp2)/m.degree;}return vals;}
  698. g.Geodesic.prototype.GenDirect=function(lat1,lon1,azi1,arcmode,s12_a12,outmask){var line=new l.GeodesicLine(this,lat1,lon1,azi1,outmask|(arcmode?g.NONE:g.DISTANCE_IN));return line.GenPosition(arcmode,s12_a12,outmask);}
  699. g.WGS84=new g.Geodesic(GeographicLib.Constants.WGS84.a,GeographicLib.Constants.WGS84.f);
  700. })();
  701. (function(){
  702. var g=GeographicLib.Geodesic;var l=GeographicLib.GeodesicLine;var m=GeographicLib.Math;
  703. l.GeodesicLine=function(geod,lat1,lon1,azi1,caps){
  704. this._a=geod._a;this._f=geod._f;this._b=geod._b;this._c2=geod._c2;this._f1=geod._f1;this._caps=!caps?g.ALL:(caps|g.LATITUDE|g.AZIMUTH);azi1=g.AngRound(m.AngNormalize(azi1));lon1=m.AngNormalize(lon1);this._lat1=lat1;this._lon1=lon1;this._azi1=azi1;var alp1=azi1*m.degree;this._salp1=azi1==-180?0:Math.sin(alp1);this._calp1=Math.abs(azi1)==90?0:Math.cos(alp1);var cbet1,sbet1,phi;phi=lat1*m.degree;sbet1=this._f1*Math.sin(phi);cbet1=Math.abs(lat1)==90?g.tiny_:Math.cos(phi);var t=m.hypot(sbet1,cbet1);sbet1/=t;cbet1/=t;this._dn1=Math.sqrt(1+geod._ep2*m.sq(sbet1));this._salp0=this._salp1*cbet1;
  705. this._calp0=m.hypot(this._calp1,this._salp1*sbet1);this._ssig1=sbet1;this._somg1=this._salp0*sbet1;this._csig1=this._comg1=sbet1!=0||this._calp1!=0?cbet1*this._calp1:1;var t=m.hypot(this._ssig1,this._csig1);this._ssig1/=t;this._csig1/=t;this._k2=m.sq(this._calp0)*geod._ep2;var eps=this._k2/(2*(1+Math.sqrt(1+this._k2))+this._k2);if(this._caps&g.CAP_C1){this._A1m1=g.A1m1f(eps);this._C1a=new Array(g.nC1_+1);g.C1f(eps,this._C1a);this._B11=g.SinCosSeries(true,this._ssig1,this._csig1,this._C1a,g.nC1_);var s=Math.sin(this._B11),c=Math.cos(this._B11);this._stau1=this._ssig1*c+this._csig1*s;this._ctau1=this._csig1*c-this._ssig1*s;}if(this._caps&g.CAP_C1p){this._C1pa=new Array(g.nC1p_+1),g.C1pf(eps,this._C1pa);}if(this._caps&g.CAP_C2){this._A2m1=g.A2m1f(eps);this._C2a=new Array(g.nC2_+1);g.C2f(eps,this._C2a);this._B21=g.SinCosSeries(true,this._ssig1,this._csig1,this._C2a,g.nC2_);}if(this._caps&g.CAP_C3){this._C3a=new Array(g.nC3_);geod.C3f(eps,this._C3a);this._A3c=-this._f*this._salp0*geod.A3f(eps);this._B31=g.SinCosSeries(true,this._ssig1,this._csig1,this._C3a,g.nC3_-1);}if(this._caps&g.CAP_C4){this._C4a=new Array(g.nC4_);geod.C4f(eps,this._C4a);this._A4=m.sq(this._a)*this._calp0*this._salp0*geod._e2;this._B41=g.SinCosSeries(false,this._ssig1,this._csig1,this._C4a,g.nC4_);}}
  706. l.GeodesicLine.prototype.GenPosition=function(arcmode,s12_a12,outmask){var vals={};outmask&=this._caps&g.OUT_ALL;if(!(arcmode||(this._caps&g.DISTANCE_IN&g.OUT_ALL))){vals.a12=Number.NaN;return vals;}var sig12,ssig12,csig12,B12=0,AB1=0;if(arcmode){sig12=s12_a12*m.degree;var s12a=Math.abs(s12_a12);s12a-=180*Math.floor(s12a/180);ssig12=s12a==0?0:Math.sin(sig12);csig12=s12a==90?0:Math.cos(sig12);}else{var tau12=s12_a12/(this._b*(1+this._A1m1)),s=Math.sin(tau12),c=Math.cos(tau12);B12=-g.SinCosSeries(true,this._stau1*c+this._ctau1*s,this._ctau1*c-this._stau1*s,this._C1pa,g.nC1p_);sig12=tau12-(B12-this._B11);ssig12=Math.sin(sig12);csig12=Math.cos(sig12);if(Math.abs(this._f)>0.01){var ssig2=this._ssig1*csig12+this._csig1*ssig12,csig2=this._csig1*csig12-this._ssig1*ssig12;B12=g.SinCosSeries(true,ssig2,csig2,this._C1a,g.nC1_);var serr=(1+this._A1m1)*(sig12+(B12-this._B11))-s12_a12/this._b;sig12=sig12-serr/Math.sqrt(1+this._k2*m.sq(ssig2));ssig12=Math.sin(sig12);csig12=Math.cos(sig12);}}var omg12,lam12,lon12;var ssig2,csig2,sbet2,cbet2,somg2,comg2,salp2, calp2;ssig2=this._ssig1*csig12+this._csig1*ssig12;csig2=this._csig1*csig12-this._ssig1*ssig12;var dn2=Math.sqrt(1+this._k2*m.sq(ssig2));if(outmask&(g.DISTANCE|g.REDUCEDLENGTH|g.GEODESICSCALE)){if(arcmode||Math.abs(this._f)>0.01){B12=g.SinCosSeries(true,ssig2,csig2,this._C1a,g.nC1_)}AB1=(1+this._A1m1)*(B12-this._B11);}sbet2=this._calp0*ssig2;cbet2=m.hypot(this._salp0,this._calp0*csig2);if(cbet2==0){cbet2=csig2=g.tiny_}somg2=this._salp0*ssig2;comg2=csig2;salp2=this._salp0;calp2=this._calp0*csig2;omg12=Math.atan2(somg2*this._comg1-comg2*this._somg1,comg2*this._comg1+somg2*this._somg1);if(outmask&g.DISTANCE){vals.s12=arcmode?this._b*((1+this._A1m1)*sig12+AB1):s12_a12}if(outmask&g.LONGITUDE){lam12=omg12+this._A3c*
  707. (sig12+(g.SinCosSeries(true,ssig2,csig2,this._C3a,g.nC3_-1)-this._B31));lon12=lam12/m.degree;lon12=m.AngNormalize2(lon12);vals.lon2=m.AngNormalize(this._lon1+lon12);}if(outmask&g.LATITUDE){vals.lat2=Math.atan2(sbet2,this._f1*cbet2)/m.degree}if(outmask&g.AZIMUTH){vals.azi2=0-Math.atan2(-salp2,calp2)/m.degree}if(outmask&(g.REDUCEDLENGTH|g.GEODESICSCALE)){var B22=g.SinCosSeries(true,ssig2,csig2,this._C2a,g.nC2_),AB2=(1+this._A2m1)*(B22-this._B21),J12=(this._A1m1-this._A2m1)*sig12+(AB1-AB2);if(outmask&g.REDUCEDLENGTH){vals.m12=this._b*((dn2*(this._csig1*ssig2)-this._dn1*(this._ssig1*csig2))-this._csig1*csig2*J12)}if(outmask&g.GEODESICSCALE){var t=this._k2*(ssig2-this._ssig1)*(ssig2+this._ssig1)/(this._dn1+dn2);vals.M12=csig12+(t*ssig2-csig2*J12)*this._ssig1/this._dn1;vals.M21=csig12-(t*this._ssig1-this._csig1*J12)*ssig2/dn2;}}
  708. if(outmask&g.AREA){var B42=g.SinCosSeries(false,ssig2,csig2,this._C4a,g.nC4_);var salp12,calp12;if(this._calp0==0||this._salp0==0){salp12=salp2*this._calp1-calp2*this._salp1;calp12=calp2*this._calp1+salp2*this._salp1;if(salp12==0&&calp12<0){salp12=g.tiny_*this._calp1;calp12=-1;}}else{salp12=this._calp0*this._salp0*(csig12<=0?this._csig1*(1-csig12)+ssig12*this._ssig1:ssig12*(this._csig1*ssig12/(1+csig12)+this._ssig1));calp12=m.sq(this._salp0)+m.sq(this._calp0)*this._csig1*csig2;}vals.S12=this._c2*Math.atan2(salp12,calp12)+this._A4*(B42-this._B41)}vals.a12=arcmode?s12_a12:sig12/m.degree;return vals;}
  709. })();
  710. GeographicLib.PolygonArea={};
  711. (function(){
  712. var m=GeographicLib.Math;var a=GeographicLib.Accumulator;var g=GeographicLib.Geodesic;var p=GeographicLib.PolygonArea;
  713. p.transit=function(lon1,lon2){lon1=m.AngNormalize(lon1);lon2=m.AngNormalize(lon2);var lon12=m.AngDiff(lon1,lon2);var cross=lon1<0&&lon2>=0&&lon12>0?1:(lon2<0&&lon1>=0&&lon12<0?-1:0);return cross;}
  714. p.PolygonArea=function(earth,polyline){this._earth=earth;this._area0=4*Math.PI*earth._c2;this._polyline=!polyline?false:polyline;this._mask=g.LATITUDE|g.LONGITUDE|g.DISTANCE|(this._polyline?g.NONE:g.AREA);if(!this._polyline){this._areasum=new a.Accumulator(0)}this._perimetersum=new a.Accumulator(0);this.Clear();}
  715. p.PolygonArea.prototype.Clear=function(){this._num=0;this._crossings=0;if(!this._polyline){this._areasum.Set(0)}this._perimetersum.Set(0);this._lat0=this._lon0=this._lat1=this._lon1=Number.NaN;}
  716. p.PolygonArea.prototype.AddPoint=function(lat,lon){if(this._num==0){this._lat0=this._lat1=lat;this._lon0=this._lon1=lon;}else{var t=this._earth.Inverse(this._lat1,this._lon1,lat,lon,this._mask);this._perimetersum.Add(t.s12);if(!this._polyline){this._areasum.Add(t.S12);this._crossings+=p.transit(this._lon1,lon);}this._lat1=lat;this._lon1=lon;}++this._num;}
  717. p.PolygonArea.prototype.AddEdge=function(azi,s){if(this._num){var t=this._earth.Direct(this._lat1,this._lon1,azi,s,this._mask);this._perimetersum.Add(s);if(!this._polyline){this._areasum.Add(t.S12);this._crossings+=p.transit(this._lon1,t.lon2);}this._lat1=t.lat2;this._lon1=t.lon2;}++this._num;}
  718. p.PolygonArea.prototype.Compute=function(reverse,sign){var vals={number:this._num};if(this._num<2){vals.perimeter=0;if(!this._polyline){vals.area=0}return vals}if(this._polyline){vals.perimeter=this._perimetersum.Sum();return vals;}var t=this._earth.Inverse(this._lat1,this._lon1,this._lat0,this._lon0,this._mask);vals.perimeter=this._perimetersum.Sum(t.s12);var tempsum=new a.Accumulator(this._areasum);tempsum.Add(t.S12);var crossings=this._crossings+p.transit(this._lon1,this._lon0);if(crossings&1){tempsum.Add((tempsum.Sum()<0?1:-1)*this._area0/2)}if(!reverse){tempsum.Negate()}if(sign){if(tempsum.Sum()>this._area0/2){tempsum.Add(-this._area0)}else if(tempsum.Sum()<=-this._area0/2){tempsum.Add(+this._area0)}}else{if(tempsum.Sum()>=this._area0){tempsum.Add(-this._area0)}else if(tempsum<0){tempsum.Add(-this._area0)}}vals.area=tempsum.Sum();return vals;}
  719. p.PolygonArea.prototype.TestPoint=function(lat,lon,reverse,sign){var vals={number:this._num+1};if(this._num==0){vals.perimeter=0;if(!this._polyline){vals.area=0}return vals;}vals.perimeter=this._perimetersum.Sum();var tempsum=this._polyline?0:this._areasum.Sum();var crossings=this._crossings;var t;for(var i=0;i<(this._polyline?1:2);++i){t=this._earth.Inverse(i==0?this._lat1:lat,i==0?this._lon1:lon,i!=0?this._lat0:lat,i!=0?this._lon0:lon,this._mask);vals.perimeter+=t.s12;if(!this._polyline){tempsum+=t.S12;crossings+=p.transit(i==0?this._lon1:lon,i!=0?this._lon0:lon);}}if(this._polyline){return vals}if(crossings&1){tempsum+=(tempsum<0?1:-1)*this._area0/2}if(!reverse){tempsum*=-1}if(sign){if(tempsum>this._area0/2){tempsum-=this._area0}else if(tempsum<=-this._area0/2){tempsum+=this._area0}}else{if(tempsum>=this._area0){tempsum-=this._area0}else if(tempsum<0){tempsum+=this._area0}}vals.area=tempsum;return vals;}
  720. p.PolygonArea.prototype.TestEdge=function(azi,s,reverse,sign){var vals={number:this._num?this._num+1:0};if(this._num==0){return vals}vals.perimeter=this._perimetersum.Sum()+s;if(this._polyline){return vals}var tempsum=this._areasum.Sum();var crossings=this._crossings;var t;t=this._earth.Direct(this._lat1,this._lon1,azi,s,this._mask);tempsum+=t.S12;crossings+=p.transit(this._lon1,t.lon2);t=this._earth(t.lat2,t.lon2,this._lat0,this._lon0,this._mask);perimeter+=t.s12;tempsum+=t.S12;crossings+=p.transit(t.lon2,this._lon0);if(crossings&1){tempsum+=(tempsum<0?1:-1)*this._area0/2}if(!reverse){tempsum*=-1}if(sign){if(tempsum>this._area0/2){tempsum-=this._area0}else if(tempsum<=-this._area0/2){tempsum+=this._area0}}else{if(tempsum>=this._area0){tempsum-=this._area0}else if(tempsum<0){tempsum+=this._area0}}vals.area=tempsum;return vals;}
  721. p.PolygonArea.prototype.CurrentPoint=function(){var vals={lat:this._lat1,lon:this._lon1};return vals;}
  722. p.Area=function(earth,points,polyline){var poly=new p.PolygonArea(earth,polyline);for(var i=0;i<points.length;++i){poly.AddPoint(points[i].lat,points[i].lon)}return poly.Compute(false,true);}
  723. })();
  724. (function(){
  725. var m=GeographicLib.Math;var g=GeographicLib.Geodesic;var l=GeographicLib.GeodesicLine;
  726. g.Geodesic.CheckPosition=function(lat,lon){if(!(Math.abs(lat)<=90)){throw new Error("latitude "+lat+" not in [-90, 90]")}if(!(lon>=-540&&lon<540)){throw new Error("longitude "+lon+" not in [-540, 540]")}return m.AngNormalize(lon);}
  727. g.Geodesic.CheckAzimuth=function(azi){if(!(azi>=-540&&azi<540)){throw new Error("longitude "+azi+" not in [-540, 540]")}return m.AngNormalize(azi);}
  728. g.Geodesic.CheckDistance=function(s){if(!(isFinite(s))){throw new Error("distance "+s+" not a finite number")}}
  729. g.Geodesic.prototype.Inverse=function(lat1,lon1,lat2,lon2,outmask){if(!outmask){outmask=g.DISTANCE|g.AZIMUTH}lon1=g.Geodesic.CheckPosition(lat1,lon1);lon2=g.Geodesic.CheckPosition(lat2,lon2);var result=this.GenInverse(lat1,lon1,lat2,lon2,outmask);result.lat1=lat1;result.lon1=lon1;result.lat2=lat2;result.lon2=lon2;return result;}
  730. g.Geodesic.prototype.Direct=function(lat1,lon1,azi1,s12,outmask){if(!outmask){outmask=g.LATITUDE|g.LONGITUDE|g.AZIMUTH;}lon1=g.Geodesic.CheckPosition(lat1,lon1);azi1=g.Geodesic.CheckAzimuth(azi1);g.Geodesic.CheckDistance(s12);var result=this.GenDirect(lat1,lon1,azi1,false,s12,outmask);result.lat1=lat1;result.lon1=lon1;result.azi1=azi1;result.s12=s12;return result;}
  731. g.Geodesic.prototype.InversePath=function(lat1,lon1,lat2,lon2,ds12,maxk){var t=this.Inverse(lat1,lon1,lat2,lon2);if(!maxk){maxk=20}if(!(ds12>0)){throw new Error("ds12 must be a positive number")}var k=Math.max(1,Math.min(maxk,Math.ceil(t.s12/ds12))),points=new Array(k+1);points[0]={lat:t.lat1,lon:t.lon1,azi:t.azi1};points[k]={lat:t.lat2,lon:t.lon2,azi:t.azi2};if(k>1){var line=new l.GeodesicLine(this,t.lat1,t.lon1,t.azi1,g.LATITUDE|g.LONGITUDE|g.AZIMUTH),da12=t.a12/k;var vals;for(var i=1;i<k;++i){vals=line.GenPosition(true,i*da12,g.LATITUDE|g.LONGITUDE|g.AZIMUTH);points[i]={lat:vals.lat2,lon:vals.lon2,azi:vals.azi2};}}return points;}
  732. g.Geodesic.prototype.DirectPath=function(lat1,lon1,azi1,s12,ds12,maxk){var t=this.Direct(lat1,lon1,azi1,s12);if(!maxk){maxk=20}if(!(ds12>0)){throw new Error("ds12 must be a positive number")}var k=Math.max(1,Math.min(maxk,Math.ceil(Math.abs(t.s12)/ds12))),points=new Array(k+1);points[0]={lat:t.lat1,lon:t.lon1,azi:t.azi1};points[k]={lat:t.lat2,lon:t.lon2,azi:t.azi2};if(k>1){var line=new l.GeodesicLine(this,t.lat1,t.lon1,t.azi1,g.LATITUDE|g.LONGITUDE|g.AZIMUTH),da12=t.a12/k;var vals;for(var i=1;i<k;++i){vals=line.GenPosition(true,i*da12,g.LATITUDE|g.LONGITUDE|g.AZIMUTH);points[i]={lat:vals.lat2,lon:vals.lon2,azi:vals.azi2};}}return points;}
  733. g.Geodesic.prototype.Area=function(points,polyline){return GeographicLib.PolygonArea.Area(this,points,polyline);}
  734. })();
  735.  
  736.  
  737.  
  738. var geod = GeographicLib.Geodesic.WGS84;
  739. var g = GeographicLib.Geodesic;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement