@konfirm/geojson 1.0.1 → 2.0.0-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -21,13 +21,16 @@ var GeoJSON = (() => {
21
21
  var main_exports = {};
22
22
  __export(main_exports, {
23
23
  SimpleGeometryIterator: () => SimpleGeometryIterator,
24
+ cartesian: () => cartesian2,
24
25
  distance: () => distance,
26
+ haversine: () => haversine2,
25
27
  intersect: () => intersect,
26
28
  isFeature: () => isFeature,
27
29
  isFeatureCollection: () => isFeatureCollection,
28
30
  isGeoJSON: () => isGeoJSON,
29
31
  isGeometry: () => isGeometry,
30
32
  isGeometryCollection: () => isGeometryCollection,
33
+ isGeometryPrimitive: () => isGeometryPrimitive,
31
34
  isLineString: () => isLineString,
32
35
  isMultiLineString: () => isMultiLineString,
33
36
  isMultiPoint: () => isMultiPoint,
@@ -40,13 +43,16 @@ var GeoJSON = (() => {
40
43
  isStrictGeoJSON: () => isStrictGeoJSON,
41
44
  isStrictGeometry: () => isStrictGeometry,
42
45
  isStrictGeometryCollection: () => isStrictGeometryCollection,
46
+ isStrictGeometryPrimitive: () => isStrictGeometryPrimitive,
43
47
  isStrictLineString: () => isStrictLineString,
44
48
  isStrictMultiLineString: () => isStrictMultiLineString,
45
49
  isStrictMultiPoint: () => isStrictMultiPoint,
46
50
  isStrictMultiPolygon: () => isStrictMultiPolygon,
47
51
  isStrictPoint: () => isStrictPoint,
48
52
  isStrictPolygon: () => isStrictPolygon,
49
- isStrictPosition: () => isStrictPosition
53
+ isStrictPosition: () => isStrictPosition,
54
+ karney: () => karney2,
55
+ vincenty: () => vincenty2
50
56
  });
51
57
 
52
58
  // node_modules/@konfirm/guard/dist/guard.es.js
@@ -157,9 +163,9 @@ var GeoJSON = (() => {
157
163
  function isNumberValue(value) {
158
164
  return isNumber(value) && Number.isFinite(value);
159
165
  }
160
- function isNumberBetween(a, b = Infinity) {
161
- const min = Math.min(a, b);
162
- const max = Math.max(a, b);
166
+ function isNumberBetween(a2, b2 = Infinity) {
167
+ const min = Math.min(a2, b2);
168
+ const max = Math.max(a2, b2);
163
169
  return (value) => isNumberValue(value) && value >= min && value <= max;
164
170
  }
165
171
 
@@ -204,11 +210,11 @@ var GeoJSON = (() => {
204
210
  isLatitude,
205
211
  isAltitude
206
212
  ),
207
- ([, s, , , n]) => s <= n
213
+ ([, s, , , n2]) => s <= n2
208
214
  );
209
215
  var isBoundingBoxWithoutAltitude = all(
210
216
  isTuple(isLongitude, isLatitude, isLongitude, isLatitude),
211
- ([, s, , n]) => s <= n
217
+ ([, s, , n2]) => s <= n2
212
218
  );
213
219
  var isBoundingBox = any(
214
220
  isBoundingBoxWithAltitude,
@@ -306,18 +312,18 @@ var GeoJSON = (() => {
306
312
  );
307
313
 
308
314
  // source/Domain/Utility/Winding.ts
309
- function winding(positions2) {
310
- return positions2.reduce((carry, [x, y], i, a) => {
311
- const [nx, ny] = a[(i + 1) % a.length];
312
- return carry + (nx - x) * (ny + y);
315
+ function shoelace(positions2) {
316
+ return positions2.reduce((carry, [x, y], i, a2) => {
317
+ const [nx, ny] = a2[(i + 1) % a2.length];
318
+ return carry + (x * ny - nx * y);
313
319
  }, 0);
314
320
  }
315
321
  var isPositionArray = isArrayOfType(isPosition);
316
322
  function isClockwiseWinding(value) {
317
- return isPositionArray(value) && winding(value) <= 0;
323
+ return isPositionArray(value) && shoelace(value) <= 0;
318
324
  }
319
325
  function isCounterClockwiseWinding(value) {
320
- return isPositionArray(value) && winding(value) >= 0;
326
+ return isPositionArray(value) && shoelace(value) >= 0;
321
327
  }
322
328
 
323
329
  // source/Domain/GeoJSON/Concept/LinearRing.ts
@@ -354,8 +360,8 @@ var GeoJSON = (() => {
354
360
  );
355
361
  var isStrictPolygonCoordinates = all(
356
362
  isArrayOfType(isStrictLinearRing),
357
- (value) => isExteriorRing(value[0]),
358
- (value) => value.slice(1).every(isInteriorRing)
363
+ (value) => isStrictExteriorRing(value[0]),
364
+ (value) => value.slice(1).every(isStrictInteriorRing)
359
365
  );
360
366
  var isStrictPolygon = isGeometryObject(
361
367
  "Polygon",
@@ -377,7 +383,7 @@ var GeoJSON = (() => {
377
383
  );
378
384
 
379
385
  // source/Domain/GeoJSON/Geometry.ts
380
- var isGeometry = any(
386
+ var isGeometryPrimitive = any(
381
387
  isPoint,
382
388
  isMultiPoint,
383
389
  isLineString,
@@ -385,7 +391,7 @@ var GeoJSON = (() => {
385
391
  isPolygon,
386
392
  isMultiPolygon
387
393
  );
388
- var isStrictGeometry = any(
394
+ var isStrictGeometryPrimitive = any(
389
395
  isStrictPoint,
390
396
  isStrictMultiPoint,
391
397
  isStrictLineString,
@@ -393,54 +399,68 @@ var GeoJSON = (() => {
393
399
  isStrictPolygon,
394
400
  isStrictMultiPolygon
395
401
  );
396
-
397
- // source/Domain/GeoJSON/GeometryCollection.ts
402
+ var isGeometry = any(
403
+ isGeometryPrimitive,
404
+ isGeometryCollection
405
+ );
406
+ var isStrictGeometry = any(
407
+ isStrictGeometryPrimitive,
408
+ isStrictGeometryCollection
409
+ );
398
410
  var isGeometryCollectionObject = all(
399
411
  isGeoJSONObject("GeometryCollection"),
400
- isKeyOfType(
401
- "geometries",
402
- isArrayOfType(any(isGeometry, isGeometryCollection))
403
- )
412
+ isKeyOfType("geometries", isArrayOfType(isGeometry))
404
413
  );
405
414
  var isStrictGeometryCollectionObject = all(
406
415
  isGeoJSONObject("GeometryCollection"),
407
- isKeyOfType(
408
- "geometries",
409
- isArrayOfType(any(isStrictGeometry, isStrictGeometryCollection))
410
- )
416
+ isKeyOfType("geometries", isArrayOfType(isStrictGeometry))
411
417
  );
412
- function isGeometryCollection(value) {
413
- return isGeometryCollectionObject(value);
418
+ function isGeometryCollection(value, isG = isGeometryPrimitive) {
419
+ return isGeometryCollectionObject(value) && value.geometries.every((g) => isG(g) || isGeometryCollection(g, isG));
414
420
  }
415
- function isStrictGeometryCollection(value) {
416
- return isStrictGeometryCollectionObject(value);
421
+ function isStrictGeometryCollection(value, isG = isStrictGeometryPrimitive) {
422
+ return isStrictGeometryCollectionObject(value) && value.geometries.every(
423
+ (g) => isG(g) || isStrictGeometryCollection(g, isG)
424
+ );
417
425
  }
418
426
 
419
427
  // source/Domain/GeoJSON/Feature.ts
420
- var isFeature = all(
428
+ var isFeatureObject = all(
421
429
  isGeoJSONObject("Feature"),
422
430
  isStructure({
423
- geometry: any(isGeometry, isGeometryCollection),
431
+ geometry: any(isNULL, isGeometry),
424
432
  properties: any(isNULL, isObject)
425
433
  })
426
434
  );
427
- var isStrictFeature = all(
435
+ var isStrictFeatureObject = all(
428
436
  isGeoJSONObject("Feature"),
429
437
  isStructure({
430
- geometry: any(isStrictGeometry, isStrictGeometryCollection),
438
+ geometry: any(isNULL, isStrictGeometry),
431
439
  properties: any(isNULL, isObject)
432
440
  })
433
441
  );
442
+ function isFeature(input, isG = any(isNULL, isGeometry)) {
443
+ return isFeatureObject(input) && isG(input.geometry);
444
+ }
445
+ function isStrictFeature(input, isG = any(isNULL, isStrictGeometry)) {
446
+ return isStrictFeatureObject(input) && isG(input.geometry);
447
+ }
434
448
 
435
449
  // source/Domain/GeoJSON/FeatureCollection.ts
436
- var isFeatureCollection = all(
450
+ var isFeatureCollectionObject = all(
437
451
  isGeoJSONObject("FeatureCollection"),
438
452
  isKeyOfType("features", isArrayOfType(isFeature))
439
453
  );
440
- var isStrictFeatureCollection = all(
454
+ var isStrictFeatureCollectionObject = all(
441
455
  isGeoJSONObject("FeatureCollection"),
442
456
  isKeyOfType("features", isArrayOfType(isStrictFeature))
443
457
  );
458
+ function isFeatureCollection(value, isG = any(isNULL, isGeometry)) {
459
+ return isFeatureCollectionObject(value) && value.features.every((feature) => isFeature(feature, isG));
460
+ }
461
+ function isStrictFeatureCollection(value, isG = any(isNULL, isGeometry)) {
462
+ return isStrictFeatureCollectionObject(value) && value.features.every((feature) => isStrictFeature(feature, isG));
463
+ }
444
464
 
445
465
  // source/Domain/GeoJSON/GeoJSON.ts
446
466
  var isGeoJSON = any(
@@ -491,11 +511,15 @@ var GeoJSON = (() => {
491
511
  }
492
512
  },
493
513
  *Feature({ geometry }, unwrap) {
494
- yield* unwrap(geometry);
514
+ if (geometry) {
515
+ yield* unwrap(geometry);
516
+ }
495
517
  },
496
518
  *FeatureCollection({ features }, unwrap) {
497
519
  for (const { geometry } of features) {
498
- yield* unwrap(geometry);
520
+ if (geometry) {
521
+ yield* unwrap(geometry);
522
+ }
499
523
  }
500
524
  }
501
525
  };
@@ -551,9 +575,9 @@ var GeoJSON = (() => {
551
575
  * @memberof IterablePairIterator
552
576
  */
553
577
  *[Symbol.iterator]() {
554
- for (const [a, b] of this.pairs(this.iterators)) {
555
- for (const one of a) {
556
- for (const two of b) {
578
+ for (const [a2, b2] of this.pairs(this.iterators)) {
579
+ for (const one of a2) {
580
+ for (const two of b2) {
557
581
  yield [one, two];
558
582
  }
559
583
  }
@@ -569,7 +593,7 @@ var GeoJSON = (() => {
569
593
  */
570
594
  pairs(source) {
571
595
  return source.flatMap(
572
- (a, i) => source.slice(i + 1).map((b) => [a, b])
596
+ (a2, i) => source.slice(i + 1).map((b2) => [a2, b2])
573
597
  );
574
598
  }
575
599
  };
@@ -601,70 +625,605 @@ var GeoJSON = (() => {
601
625
  return lon >= minLon && lon <= maxLon && lat >= minLat && lat <= maxLat;
602
626
  }
603
627
 
604
- // source/Domain/Utility/Calculate.ts
628
+ // source/Domain/Utility/Common.ts
629
+ function values(_, ...values2) {
630
+ return values2;
631
+ }
632
+
633
+ // source/Domain/Utility/Numeric.ts
634
+ function squared(n2) {
635
+ return n2 * n2;
636
+ }
637
+
638
+ // source/Domain/Utility/Geodesic.ts
639
+ var a = EARTH_RADIUS_MAJOR;
640
+ var f = 1 / EARTH_FLATTENING;
641
+ var f1 = 1 - f;
642
+ var n = f / (2 - f);
643
+ var b = a * f1;
644
+ var ep2 = f * (2 - f) / (f1 * f1);
605
645
  var D2R = Math.PI / 180;
646
+ var TINY = Number.EPSILON;
647
+ var TOL0 = Number.EPSILON;
648
+ var TOL1 = 200 * TOL0;
649
+ var TOL2 = Math.sqrt(TOL0);
650
+ var TOLB = TOL0 * TOL2;
651
+ var XTHRESH = 1e3 * TOL2;
652
+ var MAXIT1 = 20;
653
+ var MAXIT2 = MAXIT1 + 80;
654
+ var ETOL2 = 0.1 * TOL2 / Math.sqrt(Math.max(1e-3, Math.abs(f)) * Math.min(1, 1 - f / 2) / 2);
655
+ var ORDER = 6;
656
+ var A1M1_COEFF = [1, 4, 64, 0, 256];
657
+ var C1_COEFF = values`
658
+ ${-1} ${6} ${-16} ${32},
659
+ ${-9} ${64} ${-128} ${2048},
660
+ ${9} ${-16} ${768}
661
+ ${3} ${-5} ${512}
662
+ ${-7} ${1280}
663
+ ${-7} ${2048}
664
+ `;
665
+ var A2M1_COEFF = [-11, -28, -192, 0, 256];
666
+ var C2_COEFF = values`
667
+ ${1} ${2} ${16} ${32}
668
+ ${35} ${64} ${384} ${2048}
669
+ ${15} ${80} ${768}
670
+ ${7} ${35} ${512}
671
+ ${63} ${1280}
672
+ ${77} ${2048}
673
+ `;
674
+ var A3_COEFF = values`
675
+ ${-3} ${128}
676
+ ${-2} ${-3} ${64}
677
+ ${-1} ${-3} ${-1} ${16}
678
+ ${3} ${-1} ${-2} ${8}
679
+ ${1} ${-1} ${2}
680
+ ${1} ${1}
681
+ `;
682
+ var C3_COEFF = values`
683
+ ${3} ${128}
684
+ ${2} ${5} ${128}
685
+ ${-1} ${3} ${3} ${64}
686
+ ${-1} ${0} ${1} ${8}
687
+ ${-1} ${1} ${4}
688
+ ${5} ${256}
689
+ ${1} ${3} ${128}
690
+ ${-3} ${-2} ${3} ${64}
691
+ ${1} ${-3} ${2} ${32}
692
+ ${7} ${512}
693
+ ${-10} ${9} ${384}
694
+ ${5} ${-9} ${5} ${192}
695
+ ${7} ${512}
696
+ ${-14} ${7} ${512}
697
+ ${21} ${2560}
698
+ `;
699
+ function hypot(x, y) {
700
+ return Math.sqrt(x * x + y * y);
701
+ }
702
+ function copysign(x, y) {
703
+ return Math.abs(x) * (y < 0 || y === 0 && 1 / y < 0 ? -1 : 1);
704
+ }
705
+ function polyval(N, p, s, x) {
706
+ let i = s;
707
+ let n2 = N;
708
+ let y = p[i++];
709
+ while (n2-- > 0) y = y * x + p[i++];
710
+ return y;
711
+ }
712
+ function angNormalize(x) {
713
+ const v = x % 360;
714
+ return v <= -180 ? v + 360 : v > 180 ? v - 360 : v;
715
+ }
716
+ function sinCosSeries(sinx, cosx, c) {
717
+ let k = c.length;
718
+ let cn = k - 1;
719
+ const ar = 2 * (cosx - sinx) * (cosx + sinx);
720
+ let y0 = cn & 1 ? c[--k] : 0;
721
+ let y1 = 0;
722
+ cn = Math.floor(cn / 2);
723
+ while (cn--) {
724
+ y1 = ar * y0 - y1 + c[--k];
725
+ y0 = ar * y1 - y0 + c[--k];
726
+ }
727
+ return 2 * sinx * cosx * y0;
728
+ }
729
+ function astroid(x, y) {
730
+ const p = squared(x);
731
+ const q = squared(y);
732
+ const r = (p + q - 1) / 6;
733
+ const S = p * q / 4;
734
+ const r2 = squared(r);
735
+ const r3 = r * r2;
736
+ const disc = S * (S + 2 * r3);
737
+ let u = r;
738
+ if (disc >= 0) {
739
+ let T3 = S + r3;
740
+ T3 += Math.sqrt(disc);
741
+ const T = Math.cbrt(T3);
742
+ u += T + r2 / T;
743
+ } else {
744
+ const ang = Math.atan2(Math.sqrt(-disc), -(S + r3));
745
+ u += 2 * r * Math.cos(ang / 3);
746
+ }
747
+ const v = Math.sqrt(squared(u) + q);
748
+ const uv = u < 0 ? q / (v - u) : u + v;
749
+ const w = (uv - q) / (2 * v);
750
+ return uv / (Math.sqrt(uv + squared(w)) + w);
751
+ }
752
+ function A1m1f(eps) {
753
+ const p = Math.floor(ORDER / 2);
754
+ const t = polyval(p, A1M1_COEFF, 0, squared(eps)) / A1M1_COEFF[p + 1];
755
+ return (t + eps) / (1 - eps);
756
+ }
757
+ function C1f(eps, c) {
758
+ const eps2 = squared(eps);
759
+ let d = eps;
760
+ let o = 0;
761
+ for (let l = 1; l <= ORDER; l++) {
762
+ const p = Math.floor((ORDER - l) / 2);
763
+ c[l] = d * polyval(p, C1_COEFF, o, eps2) / C1_COEFF[o + p + 1];
764
+ o += p + 2;
765
+ d *= eps;
766
+ }
767
+ }
768
+ function A2m1f(eps) {
769
+ const p = Math.floor(ORDER / 2);
770
+ const t = polyval(p, A2M1_COEFF, 0, squared(eps)) / A2M1_COEFF[p + 1];
771
+ return (t - eps) / (1 + eps);
772
+ }
773
+ function C2f(eps, c) {
774
+ const eps2 = squared(eps);
775
+ let d = eps;
776
+ let o = 0;
777
+ for (let l = 1; l <= ORDER; l++) {
778
+ const p = Math.floor((ORDER - l) / 2);
779
+ c[l] = d * polyval(p, C2_COEFF, o, eps2) / C2_COEFF[o + p + 1];
780
+ o += p + 2;
781
+ d *= eps;
782
+ }
783
+ }
784
+ function buildA3x() {
785
+ const ax = new Array(ORDER);
786
+ let o = 0;
787
+ let k = 0;
788
+ for (let j = ORDER - 1; j >= 0; j--) {
789
+ const p = Math.min(ORDER - j - 1, j);
790
+ ax[k++] = polyval(p, A3_COEFF, o, n) / A3_COEFF[o + p + 1];
791
+ o += p + 2;
792
+ }
793
+ return ax;
794
+ }
795
+ function buildC3x() {
796
+ const cx = [];
797
+ let o = 0;
798
+ for (let l = 1; l < ORDER; l++) {
799
+ for (let j = ORDER - 1; j >= l; j--) {
800
+ const p = Math.min(ORDER - j - 1, j);
801
+ cx.push(polyval(p, C3_COEFF, o, n) / C3_COEFF[o + p + 1]);
802
+ o += p + 2;
803
+ }
804
+ }
805
+ return cx;
806
+ }
807
+ var A3x = buildA3x();
808
+ var C3x = buildC3x();
809
+ function A3f(eps) {
810
+ return polyval(ORDER - 1, A3x, 0, eps);
811
+ }
812
+ function C3f(eps, c) {
813
+ let mult = 1;
814
+ let o = 0;
815
+ for (let l = 1; l < ORDER; l++) {
816
+ const p = ORDER - l - 1;
817
+ mult *= eps;
818
+ c[l] = mult * polyval(p, C3x, o, eps);
819
+ o += p + 1;
820
+ }
821
+ }
822
+ function geodesicLengths(eps, sig12, ssig1, csig1, dn1, ssig2, csig2, dn2, C1a, C2a) {
823
+ C1f(eps, C1a);
824
+ C2f(eps, C2a);
825
+ const a1 = A1m1f(eps);
826
+ const a2 = A2m1f(eps);
827
+ const m0x = a1 - a2;
828
+ const A1 = 1 + a1;
829
+ const A2 = 1 + a2;
830
+ const B1 = sinCosSeries(ssig2, csig2, C1a) - sinCosSeries(ssig1, csig1, C1a);
831
+ const B2 = sinCosSeries(ssig2, csig2, C2a) - sinCosSeries(ssig1, csig1, C2a);
832
+ const J12 = m0x * sig12 + (A1 * B1 - A2 * B2);
833
+ return {
834
+ s12b: A1 * (sig12 + B1),
835
+ m12b: dn2 * (csig1 * ssig2) - dn1 * (ssig1 * csig2) - csig1 * csig2 * J12
836
+ };
837
+ }
838
+ function Lambda12(sbet1, cbet1, dn1, sbet2, cbet2, dn2, salp1, calp1, slam12, clam12, _diffp, C1a, C2a, C3a) {
839
+ const salp0 = salp1 * cbet1;
840
+ const calp0 = hypot(calp1, salp1 * sbet1);
841
+ let ssig1 = sbet1;
842
+ const somg1 = salp0 * sbet1;
843
+ let csig1 = calp1 * cbet1;
844
+ const comg1 = csig1;
845
+ let t = hypot(ssig1, csig1);
846
+ ssig1 /= t;
847
+ csig1 /= t;
848
+ const salp2 = cbet2 !== cbet1 ? salp0 / cbet2 : salp1;
849
+ const calp2 = cbet2 !== cbet1 || Math.abs(sbet2) !== -sbet1 ? Math.sqrt(
850
+ squared(calp1 * cbet1) + (cbet1 < -sbet1 ? (cbet2 - cbet1) * (cbet1 + cbet2) : (sbet1 - sbet2) * (sbet1 + sbet2))
851
+ ) / cbet2 : Math.abs(calp1);
852
+ let ssig2 = sbet2;
853
+ const somg2 = salp0 * sbet2;
854
+ let csig2 = calp2 * cbet2;
855
+ const comg2 = csig2;
856
+ t = hypot(ssig2, csig2);
857
+ ssig2 /= t;
858
+ csig2 /= t;
859
+ const sig12 = Math.atan2(
860
+ Math.max(0, csig1 * ssig2 - ssig1 * csig2),
861
+ csig1 * csig2 + ssig1 * ssig2
862
+ );
863
+ const somg12 = Math.max(0, comg1 * somg2 - somg1 * comg2);
864
+ const comg12 = comg1 * comg2 + somg1 * somg2;
865
+ const eta = Math.atan2(
866
+ somg12 * clam12 - comg12 * slam12,
867
+ comg12 * clam12 + somg12 * slam12
868
+ );
869
+ const k2 = squared(calp0) * ep2;
870
+ const eps = k2 / (2 * (1 + Math.sqrt(1 + k2)) + k2);
871
+ C3f(eps, C3a);
872
+ const B312 = sinCosSeries(ssig2, csig2, C3a) - sinCosSeries(ssig1, csig1, C3a);
873
+ const domg12 = -f * A3f(eps) * salp0 * (sig12 + B312);
874
+ const lam12 = eta + domg12;
875
+ let dlam12;
876
+ if (calp2 === 0) {
877
+ dlam12 = -2 * f1 * dn1 / sbet1;
878
+ } else {
879
+ const nv = geodesicLengths(
880
+ eps,
881
+ sig12,
882
+ ssig1,
883
+ csig1,
884
+ dn1,
885
+ ssig2,
886
+ csig2,
887
+ dn2,
888
+ C1a,
889
+ C2a
890
+ );
891
+ dlam12 = nv.m12b * f1 / (calp2 * cbet2);
892
+ }
893
+ return {
894
+ lam12,
895
+ dlam12,
896
+ salp2,
897
+ calp2,
898
+ sig12,
899
+ ssig1,
900
+ csig1,
901
+ ssig2,
902
+ csig2,
903
+ eps
904
+ };
905
+ }
906
+ function inverseStart(sbet1, cbet1, _dn1, sbet2, cbet2, _dn2, lam12, slam12, clam12, _C1a, _C2a) {
907
+ const sbet12 = sbet2 * cbet1 - cbet2 * sbet1;
908
+ const cbet12 = cbet2 * cbet1 + sbet2 * sbet1;
909
+ const sbet12a = sbet2 * cbet1 + cbet2 * sbet1;
910
+ const shortline = cbet12 >= 0 && sbet12 < 0.5 && cbet2 * lam12 < 0.5;
911
+ let somg12;
912
+ let comg12;
913
+ let dnm = 1;
914
+ if (shortline) {
915
+ const sbetm2 = squared(sbet1 + sbet2) / (squared(sbet1 + sbet2) + squared(cbet1 + cbet2));
916
+ dnm = Math.sqrt(1 + ep2 * sbetm2);
917
+ const omg12 = lam12 / (f1 * dnm);
918
+ somg12 = Math.sin(omg12);
919
+ comg12 = Math.cos(omg12);
920
+ } else {
921
+ somg12 = slam12;
922
+ comg12 = clam12;
923
+ }
924
+ let salp1 = cbet2 * somg12;
925
+ let calp1 = comg12 >= 0 ? sbet12 + cbet2 * sbet1 * squared(somg12) / (1 + comg12) : sbet12a - cbet2 * sbet1 * squared(somg12) / (1 - comg12);
926
+ const ssig12 = hypot(salp1, calp1);
927
+ const csig12 = sbet1 * sbet2 + cbet1 * cbet2 * comg12;
928
+ let salp2 = 0;
929
+ let calp2 = 0;
930
+ let sig12 = -1;
931
+ if (shortline && ssig12 < ETOL2) {
932
+ salp2 = cbet1 * somg12;
933
+ calp2 = sbet12 - cbet1 * sbet2 * squared(somg12) / (1 + comg12);
934
+ const nt = hypot(salp2, calp2);
935
+ salp2 /= nt;
936
+ calp2 /= nt;
937
+ sig12 = Math.atan2(ssig12, csig12);
938
+ } else if (Math.abs(n) > 0.1 || csig12 >= 0 || ssig12 >= 6 * Math.abs(n) * Math.PI * squared(cbet1)) {
939
+ } else {
940
+ const lam12x = Math.atan2(-slam12, -clam12);
941
+ const k2 = squared(sbet1) * ep2;
942
+ const eps = k2 / (2 * (1 + Math.sqrt(1 + k2)) + k2);
943
+ const lamscale = f * cbet1 * A3f(eps) * Math.PI;
944
+ const betscale = lamscale * cbet1;
945
+ const x = lam12x / lamscale;
946
+ const y = sbet12a / betscale;
947
+ if (y > -TOL1 && x > -1 - XTHRESH) {
948
+ salp1 = Math.min(1, -x);
949
+ calp1 = -Math.sqrt(1 - squared(salp1));
950
+ } else {
951
+ const k = astroid(x, y);
952
+ const omg12a = lamscale * (-x * k / (1 + k));
953
+ somg12 = Math.sin(omg12a);
954
+ comg12 = -Math.cos(omg12a);
955
+ salp1 = cbet2 * somg12;
956
+ calp1 = sbet12a - cbet2 * sbet1 * squared(somg12) / (1 - comg12);
957
+ }
958
+ }
959
+ if (!(salp1 <= 0)) {
960
+ const nt = hypot(salp1, calp1);
961
+ salp1 /= nt;
962
+ calp1 /= nt;
963
+ } else {
964
+ salp1 = 1;
965
+ calp1 = 0;
966
+ }
967
+ return { sig12, salp1, calp1, salp2, calp2, dnm };
968
+ }
969
+ function inverseDistance(lat1, lon1, lat2, lon2) {
970
+ let \u03C61 = Math.max(-90, Math.min(90, lat1));
971
+ let \u03C62 = Math.max(-90, Math.min(90, lat2));
972
+ let lon12 = angNormalize(angNormalize(lon2) - angNormalize(lon1));
973
+ const lonsign = lon12 >= 0 ? 1 : -1;
974
+ lon12 = lonsign * lon12;
975
+ const slam12 = lon12 === 180 ? 0 : Math.sin(lon12 * D2R);
976
+ const clam12 = Math.cos(lon12 * D2R);
977
+ const swapp = Math.abs(\u03C61) >= Math.abs(\u03C62) ? 1 : -1;
978
+ if (swapp < 0) [\u03C62, \u03C61] = [\u03C61, \u03C62];
979
+ const latsign = \u03C61 <= 0 ? 1 : -1;
980
+ \u03C61 *= latsign;
981
+ \u03C62 *= latsign;
982
+ let sbet1 = f1 * Math.sin(\u03C61 * D2R);
983
+ let cbet1 = Math.cos(\u03C61 * D2R);
984
+ let t = hypot(sbet1, cbet1);
985
+ sbet1 /= t;
986
+ cbet1 /= t;
987
+ cbet1 = Math.max(TINY, cbet1);
988
+ let sbet2 = f1 * Math.sin(\u03C62 * D2R);
989
+ let cbet2 = Math.cos(\u03C62 * D2R);
990
+ t = hypot(sbet2, cbet2);
991
+ sbet2 /= t;
992
+ cbet2 /= t;
993
+ cbet2 = Math.max(TINY, cbet2);
994
+ if (cbet1 < -sbet1) {
995
+ if (cbet2 === cbet1) sbet2 = copysign(sbet1, sbet2);
996
+ } else {
997
+ if (Math.abs(sbet2) === -sbet1) cbet2 = cbet1;
998
+ }
999
+ const dn1 = Math.sqrt(1 + ep2 * squared(sbet1));
1000
+ const dn2 = Math.sqrt(1 + ep2 * squared(sbet2));
1001
+ const lam12 = lon12 * D2R;
1002
+ const C1a = new Array(ORDER + 1);
1003
+ const C2a = new Array(ORDER + 1);
1004
+ const C3a = new Array(ORDER);
1005
+ let s12b;
1006
+ let calp1;
1007
+ let salp1;
1008
+ let calp2;
1009
+ let ssig1;
1010
+ let csig1;
1011
+ let ssig2;
1012
+ let csig2;
1013
+ let eps;
1014
+ const meridian = \u03C61 === -90 || slam12 === 0;
1015
+ if (meridian) {
1016
+ calp1 = clam12;
1017
+ salp1 = slam12;
1018
+ calp2 = 1;
1019
+ ssig1 = sbet1;
1020
+ csig1 = calp1 * cbet1;
1021
+ ssig2 = sbet2;
1022
+ csig2 = calp2 * cbet2;
1023
+ const sig12m = Math.atan2(
1024
+ Math.max(0, csig1 * ssig2 - ssig1 * csig2),
1025
+ csig1 * csig2 + ssig1 * ssig2
1026
+ );
1027
+ eps = n;
1028
+ const nv2 = geodesicLengths(
1029
+ eps,
1030
+ sig12m,
1031
+ ssig1,
1032
+ csig1,
1033
+ dn1,
1034
+ ssig2,
1035
+ csig2,
1036
+ dn2,
1037
+ C1a,
1038
+ C2a
1039
+ );
1040
+ s12b = nv2.s12b;
1041
+ if (sig12m < 3 * TINY) {
1042
+ s12b = 0;
1043
+ }
1044
+ return b * s12b;
1045
+ }
1046
+ if (sbet1 === 0 && (f <= 0 || 180 - lon12 >= f * 180)) {
1047
+ return a * lam12;
1048
+ }
1049
+ const ns = inverseStart(
1050
+ sbet1,
1051
+ cbet1,
1052
+ dn1,
1053
+ sbet2,
1054
+ cbet2,
1055
+ dn2,
1056
+ lam12,
1057
+ slam12,
1058
+ clam12,
1059
+ C1a,
1060
+ C2a
1061
+ );
1062
+ let sig12 = ns.sig12;
1063
+ salp1 = ns.salp1;
1064
+ calp1 = ns.calp1;
1065
+ if (sig12 >= 0) {
1066
+ calp2 = ns.calp2;
1067
+ s12b = sig12 * b * ns.dnm;
1068
+ return s12b;
1069
+ }
1070
+ calp2 = 0;
1071
+ ssig1 = 0;
1072
+ csig1 = 0;
1073
+ ssig2 = 0;
1074
+ csig2 = 0;
1075
+ eps = 0;
1076
+ let salp1a = TINY;
1077
+ let calp1a = 1;
1078
+ let salp1b = TINY;
1079
+ let calp1b = -1;
1080
+ let tripn = false;
1081
+ let tripb = false;
1082
+ for (let numit = 0; ; ++numit) {
1083
+ const lv = Lambda12(
1084
+ sbet1,
1085
+ cbet1,
1086
+ dn1,
1087
+ sbet2,
1088
+ cbet2,
1089
+ dn2,
1090
+ salp1,
1091
+ calp1,
1092
+ slam12,
1093
+ clam12,
1094
+ numit < MAXIT1,
1095
+ C1a,
1096
+ C2a,
1097
+ C3a
1098
+ );
1099
+ const v = lv.lam12;
1100
+ calp2 = lv.calp2;
1101
+ sig12 = lv.sig12;
1102
+ ssig1 = lv.ssig1;
1103
+ csig1 = lv.csig1;
1104
+ ssig2 = lv.ssig2;
1105
+ csig2 = lv.csig2;
1106
+ eps = lv.eps;
1107
+ const dv = lv.dlam12;
1108
+ if (tripb || !(Math.abs(v) >= (tripn ? 8 : 1) * TOL0) || numit === MAXIT2)
1109
+ break;
1110
+ if (v > 0) {
1111
+ salp1b = salp1;
1112
+ calp1b = calp1;
1113
+ }
1114
+ if (v < 0) {
1115
+ salp1a = salp1;
1116
+ calp1a = calp1;
1117
+ }
1118
+ {
1119
+ const dalp1 = -v / dv;
1120
+ const sdalp1 = Math.sin(dalp1);
1121
+ const cdalp1 = Math.cos(dalp1);
1122
+ const nsalp1 = salp1 * cdalp1 + calp1 * sdalp1;
1123
+ if (nsalp1 > 0) {
1124
+ calp1 = calp1 * cdalp1 - salp1 * sdalp1;
1125
+ salp1 = nsalp1;
1126
+ t = hypot(salp1, calp1);
1127
+ salp1 /= t;
1128
+ calp1 /= t;
1129
+ tripn = Math.abs(v) <= 16 * TOL0;
1130
+ continue;
1131
+ }
1132
+ }
1133
+ salp1 = (salp1a + salp1b) / 2;
1134
+ calp1 = (calp1a + calp1b) / 2;
1135
+ t = hypot(salp1, calp1);
1136
+ salp1 /= t;
1137
+ calp1 /= t;
1138
+ tripn = false;
1139
+ tripb = Math.abs(salp1a - salp1) + (calp1a - calp1) < TOLB || Math.abs(salp1 - salp1b) + (calp1 - calp1b) < TOLB;
1140
+ }
1141
+ const nv = geodesicLengths(
1142
+ eps,
1143
+ sig12,
1144
+ ssig1,
1145
+ csig1,
1146
+ dn1,
1147
+ ssig2,
1148
+ csig2,
1149
+ dn2,
1150
+ C1a,
1151
+ C2a
1152
+ );
1153
+ return b * nv.s12b;
1154
+ }
1155
+ function karney([lon1, lat1], [lon2, lat2]) {
1156
+ return inverseDistance(lat1, lon1, lat2, lon2);
1157
+ }
1158
+
1159
+ // source/Domain/Utility/Calculate.ts
1160
+ var D2R2 = Math.PI / 180;
606
1161
  var \u03C0 = Math.PI;
607
1162
  function constrain(value, min, max) {
608
1163
  return Math.max(Math.min(value, max), min);
609
1164
  }
610
- function squared(n) {
611
- return n * n;
612
- }
613
- function rad(n) {
614
- return n * D2R;
1165
+ function rad(n2) {
1166
+ return n2 * D2R2;
615
1167
  }
616
1168
  var EARTH_RADIUS_MAJOR_SQUARED = squared(EARTH_RADIUS_MAJOR);
617
1169
  var EARTH_RADIUS_MINOR_SQUARED = squared(EARTH_RADIUS_MINOR);
618
1170
  var EARTH_RADIUS_FACTOR = (EARTH_RADIUS_MAJOR_SQUARED - EARTH_RADIUS_MINOR_SQUARED) / EARTH_RADIUS_MINOR_SQUARED;
619
1171
  var EARTH_INVERSE_FLATTENING = 1 / EARTH_FLATTENING;
1172
+ function cartesian([\u03BBa, \u03C6a], [\u03BBb, \u03C6b]) {
1173
+ return EARTH_RADIUS * rad(Math.sqrt(squared(\u03BBb - \u03BBa) + squared(\u03C6b - \u03C6a)));
1174
+ }
1175
+ function haversine([\u03BBa, \u03C6a], [\u03BBb, \u03C6b]) {
1176
+ const \u0394 = squared(Math.sin(rad(\u03C6b - \u03C6a) / 2)) + Math.cos(rad(\u03C6a)) * Math.cos(rad(\u03C6b)) * squared(Math.sin(rad(\u03BBb - \u03BBa) / 2));
1177
+ return EARTH_RADIUS * Math.atan2(Math.sqrt(\u0394), Math.sqrt(1 - \u0394)) * 2;
1178
+ }
1179
+ function vincenty(a2, b2) {
1180
+ const [[\u03BB1, \u03C61], [\u03BB2, \u03C62]] = [a2, b2].map((p) => p.map(rad));
1181
+ const L = \u03BB2 - \u03BB1;
1182
+ const tanU1 = (1 - EARTH_INVERSE_FLATTENING) * Math.tan(\u03C61), cosU1 = 1 / Math.sqrt(1 + tanU1 * tanU1), sinU1 = tanU1 * cosU1;
1183
+ const tanU2 = (1 - EARTH_INVERSE_FLATTENING) * Math.tan(\u03C62), cosU2 = 1 / Math.sqrt(1 + tanU2 * tanU2), sinU2 = tanU2 * cosU2;
1184
+ const antipodal = Math.abs(L) > \u03C0 / 2 || Math.abs(\u03C62 - \u03C61) > \u03C0 / 2;
1185
+ let \u03BB = L;
1186
+ let sin\u03BB = null;
1187
+ let cos\u03BB = null;
1188
+ let \u03C3 = antipodal ? \u03C0 : 0;
1189
+ let sin\u03C3 = 0;
1190
+ let cos\u03C3 = antipodal ? -1 : 1;
1191
+ let sinSq\u03C3 = null;
1192
+ let cos2\u03C3\u2098 = 1;
1193
+ let cosSq\u03B1 = 1;
1194
+ let \u03BB\u02B9 = null;
1195
+ let prev\u0394\u03BB = Infinity;
1196
+ let iterations = 0;
1197
+ do {
1198
+ sin\u03BB = Math.sin(\u03BB);
1199
+ cos\u03BB = Math.cos(\u03BB);
1200
+ sinSq\u03C3 = (cosU2 * sin\u03BB) ** 2 + (cosU1 * sinU2 - sinU1 * cosU2 * cos\u03BB) ** 2;
1201
+ if (Math.abs(sinSq\u03C3) < 1e-24) break;
1202
+ sin\u03C3 = Math.sqrt(sinSq\u03C3);
1203
+ cos\u03C3 = sinU1 * sinU2 + cosU1 * cosU2 * cos\u03BB;
1204
+ \u03C3 = Math.atan2(sin\u03C3, cos\u03C3);
1205
+ const sin\u03B1 = cosU1 * cosU2 * sin\u03BB / sin\u03C3;
1206
+ cosSq\u03B1 = 1 - sin\u03B1 * sin\u03B1;
1207
+ cos2\u03C3\u2098 = cosSq\u03B1 !== 0 ? cos\u03C3 - 2 * sinU1 * sinU2 / cosSq\u03B1 : 0;
1208
+ const C = EARTH_INVERSE_FLATTENING / 16 * cosSq\u03B1 * (4 + EARTH_INVERSE_FLATTENING * (4 - 3 * cosSq\u03B1));
1209
+ \u03BB\u02B9 = \u03BB;
1210
+ \u03BB = L + (1 - C) * EARTH_INVERSE_FLATTENING * sin\u03B1 * (\u03C3 + C * sin\u03C3 * (cos2\u03C3\u2098 + C * cos\u03C3 * (-1 + 2 * cos2\u03C3\u2098 * cos2\u03C3\u2098)));
1211
+ const \u0394\u03BB = Math.abs(\u03BB - \u03BB\u02B9);
1212
+ if (\u0394\u03BB !== 0 && \u0394\u03BB === prev\u0394\u03BB || ++iterations > 1e3)
1213
+ throw new EvalError("Vincenty formula failed to converge");
1214
+ prev\u0394\u03BB = \u0394\u03BB;
1215
+ } while (Math.abs(\u03BB - \u03BB\u02B9) > 1e-12);
1216
+ const uSq = cosSq\u03B1 * EARTH_RADIUS_FACTOR;
1217
+ const A = 1 + uSq / 16384 * (4096 + uSq * (-768 + uSq * (320 - 175 * uSq)));
1218
+ const B = uSq / 1024 * (256 + uSq * (-128 + uSq * (74 - 47 * uSq)));
1219
+ const \u0394\u03C3 = B * sin\u03C3 * (cos2\u03C3\u2098 + B / 4 * (cos\u03C3 * (-1 + 2 * cos2\u03C3\u2098 * cos2\u03C3\u2098) - B / 6 * cos2\u03C3\u2098 * (-3 + 4 * sin\u03C3 * sin\u03C3) * (-3 + 4 * cos2\u03C3\u2098 * cos2\u03C3\u2098)));
1220
+ return EARTH_RADIUS_MINOR * A * (\u03C3 - \u0394\u03C3);
1221
+ }
620
1222
  var PointToPoint = {
621
- cartesian([\u03BBa, \u03C6a], [\u03BBb, \u03C6b]) {
622
- return EARTH_RADIUS * rad(Math.sqrt(squared(\u03BBb - \u03BBa) + squared(\u03C6b - \u03C6a)));
623
- },
624
- haversine([\u03BBa, \u03C6a], [\u03BBb, \u03C6b]) {
625
- const \u0394 = squared(Math.sin(rad(\u03C6b - \u03C6a) / 2)) + Math.cos(rad(\u03C6a)) * Math.cos(rad(\u03C6b)) * squared(Math.sin(rad(\u03BBb - \u03BBa) / 2));
626
- return EARTH_RADIUS * Math.atan2(Math.sqrt(\u0394), Math.sqrt(1 - \u0394)) * 2;
627
- },
628
- vincenty(...points) {
629
- const [[\u03BB1, \u03C61], [\u03BB2, \u03C62]] = points.map(
630
- (p) => p.map(rad)
631
- );
632
- const L = \u03BB2 - \u03BB1;
633
- const tanU1 = (1 - EARTH_INVERSE_FLATTENING) * Math.tan(\u03C61), cosU1 = 1 / Math.sqrt(1 + tanU1 * tanU1), sinU1 = tanU1 * cosU1;
634
- const tanU2 = (1 - EARTH_INVERSE_FLATTENING) * Math.tan(\u03C62), cosU2 = 1 / Math.sqrt(1 + tanU2 * tanU2), sinU2 = tanU2 * cosU2;
635
- const antipodal = Math.abs(L) > \u03C0 / 2 || Math.abs(\u03C62 - \u03C61) > \u03C0 / 2;
636
- let \u03BB = L;
637
- let sin\u03BB = null;
638
- let cos\u03BB = null;
639
- let \u03C3 = antipodal ? \u03C0 : 0;
640
- let sin\u03C3 = 0;
641
- let cos\u03C3 = antipodal ? -1 : 1;
642
- let sinSq\u03C3 = null;
643
- let cos2\u03C3\u2098 = 1;
644
- let cosSq\u03B1 = 1;
645
- let \u03BB\u02B9 = null;
646
- let iterations = 0;
647
- do {
648
- sin\u03BB = Math.sin(\u03BB);
649
- cos\u03BB = Math.cos(\u03BB);
650
- sinSq\u03C3 = (cosU2 * sin\u03BB) ** 2 + (cosU1 * sinU2 - sinU1 * cosU2 * cos\u03BB) ** 2;
651
- if (Math.abs(sinSq\u03C3) < 1e-24) break;
652
- sin\u03C3 = Math.sqrt(sinSq\u03C3);
653
- cos\u03C3 = sinU1 * sinU2 + cosU1 * cosU2 * cos\u03BB;
654
- \u03C3 = Math.atan2(sin\u03C3, cos\u03C3);
655
- const sin\u03B1 = cosU1 * cosU2 * sin\u03BB / sin\u03C3;
656
- cosSq\u03B1 = 1 - sin\u03B1 * sin\u03B1;
657
- cos2\u03C3\u2098 = cosSq\u03B1 !== 0 ? cos\u03C3 - 2 * sinU1 * sinU2 / cosSq\u03B1 : 0;
658
- const C = EARTH_INVERSE_FLATTENING / 16 * cosSq\u03B1 * (4 + EARTH_INVERSE_FLATTENING * (4 - 3 * cosSq\u03B1));
659
- \u03BB\u02B9 = \u03BB;
660
- \u03BB = L + (1 - C) * EARTH_INVERSE_FLATTENING * sin\u03B1 * (\u03C3 + C * sin\u03C3 * (cos2\u03C3\u2098 + C * cos\u03C3 * (-1 + 2 * cos2\u03C3\u2098 * cos2\u03C3\u2098)));
661
- } while (Math.abs(\u03BB - \u03BB\u02B9) > 1e-12 && ++iterations < 1e3);
662
- const uSq = cosSq\u03B1 * EARTH_RADIUS_FACTOR;
663
- const A = 1 + uSq / 16384 * (4096 + uSq * (-768 + uSq * (320 - 175 * uSq)));
664
- const B = uSq / 1024 * (256 + uSq * (-128 + uSq * (74 - 47 * uSq)));
665
- const \u0394\u03C3 = B * sin\u03C3 * (cos2\u03C3\u2098 + B / 4 * (cos\u03C3 * (-1 + 2 * cos2\u03C3\u2098 * cos2\u03C3\u2098) - B / 6 * cos2\u03C3\u2098 * (-3 + 4 * sin\u03C3 * sin\u03C3) * (-3 + 4 * cos2\u03C3\u2098 * cos2\u03C3\u2098)));
666
- return EARTH_RADIUS_MINOR * A * (\u03C3 - \u0394\u03C3);
667
- }
1223
+ cartesian,
1224
+ haversine,
1225
+ vincenty,
1226
+ karney
668
1227
  };
669
1228
  function getClosestPointOnLineByPoint(point, line) {
670
1229
  const [[px, py], [ax, ay], [bx, by]] = [point, ...line];
@@ -677,10 +1236,10 @@ var GeoJSON = (() => {
677
1236
  );
678
1237
  return t === 0 || t === 1 ? line[t] : [ax + abx * t, ay + aby * t];
679
1238
  }
680
- function getDistanceOfPointToPoint(a, b, calculation) {
1239
+ function getDistanceOfPointToPoint(a2, b2, calculation) {
681
1240
  const calc = typeof calculation === "function" ? calculation : PointToPoint[calculation];
682
1241
  if (typeof calc === "function") {
683
- return calc(a, b);
1242
+ return calc(a2, b2);
684
1243
  }
685
1244
  throw new Error(`Not a PointToPoint calculation function ${calculation}`);
686
1245
  }
@@ -691,15 +1250,15 @@ var GeoJSON = (() => {
691
1250
  calculation
692
1251
  );
693
1252
  }
694
- function getDistanceOfLineToLine(a, b, calculation) {
695
- return isLinesCrossing(a, b) ? 0 : Math.min(
696
- ...a.map((a2) => getDistanceOfPointToLine(a2, b, calculation)),
697
- ...b.map((b2) => getDistanceOfPointToLine(b2, a, calculation))
1253
+ function getDistanceOfLineToLine(a2, b2, calculation) {
1254
+ return isLinesCrossing(a2, b2) ? 0 : Math.min(
1255
+ ...a2.map((a3) => getDistanceOfPointToLine(a3, b2, calculation)),
1256
+ ...b2.map((b3) => getDistanceOfPointToLine(b3, a2, calculation))
698
1257
  );
699
1258
  }
700
- function isLinesCrossing(a, b) {
701
- const [[a1x, a1y], [a2x, a2y]] = a;
702
- const [[b1x, b1y], [b2x, b2y]] = b;
1259
+ function isLinesCrossing(a2, b2) {
1260
+ const [[a1x, a1y], [a2x, a2y]] = a2;
1261
+ const [[b1x, b1y], [b2x, b2y]] = b2;
703
1262
  const [s1x, s1y, s2x, s2y] = [a2x - a1x, a2y - a1y, b2x - b1x, b2y - b1y];
704
1263
  const s = (-s1y * (a1x - b1x) + s1x * (a1y - b1y)) / (-s2x * s1y + s1x * s2y);
705
1264
  const t = (s2x * (a1y - b1y) - s2y * (a1x - b1x)) / (-s2x * s1y + s1x * s2y);
@@ -713,13 +1272,13 @@ var GeoJSON = (() => {
713
1272
  return false;
714
1273
  }
715
1274
  const { length } = ring;
716
- const odd = ring.reduce((odd2, a, i) => {
717
- const b = ring[(length + i - 1) % length];
718
- return (a[1] < p[1] && b[1] >= p[1] || b[1] < p[1] && a[1] >= p[1]) && (a[0] <= p[0] || b[0] <= p[0]) ? odd2 ^ Number(
719
- a[0] + (p[1] - a[1]) / (b[1] - a[1]) * (b[0] - a[0]) < p[0]
1275
+ const odd = ring.reduce((odd2, a2, i) => {
1276
+ const b2 = ring[(length + i - 1) % length];
1277
+ return (a2[1] < p[1] && b2[1] >= p[1] || b2[1] < p[1] && a2[1] >= p[1]) && (a2[0] <= p[0] || b2[0] <= p[0]) ? odd2 ^ Number(
1278
+ a2[0] + (p[1] - a2[1]) / (b2[1] - a2[1]) * (b2[0] - a2[0]) < p[0]
720
1279
  ) : odd2;
721
1280
  }, 0);
722
- return odd !== 0 || ring.slice(1).some((a, index) => isPointOnLine(p, [ring[index], a]));
1281
+ return odd !== 0 || ring.slice(1).some((a2, index) => isPointOnLine(p, [ring[index], a2]));
723
1282
  }
724
1283
 
725
1284
  // source/Domain/Utility/Segments.ts
@@ -729,76 +1288,88 @@ var GeoJSON = (() => {
729
1288
 
730
1289
  // source/Domain/Utility/Distance.ts
731
1290
  var geometries = {
732
- PointPoint(a, b, calculation) {
733
- return getDistanceOfPointToPoint(a, b, calculation);
1291
+ PointPoint(a2, b2, calculation) {
1292
+ return getDistanceOfPointToPoint(a2, b2, calculation);
734
1293
  },
735
- LineStringPoint(a, b, calculation) {
1294
+ LineStringPoint(a2, b2, calculation) {
736
1295
  return Math.min(
737
- ...segments(a).map(
738
- (line) => getDistanceOfPointToLine(b, line, calculation)
1296
+ ...segments(a2).map(
1297
+ (line) => getDistanceOfPointToLine(b2, line, calculation)
739
1298
  )
740
1299
  );
741
1300
  },
742
- LineStringLineString(a, b, calculation) {
743
- const sa = segments(a);
744
- const sb = segments(b);
1301
+ LineStringLineString(a2, b2, calculation) {
1302
+ const sa = segments(a2);
1303
+ const sb = segments(b2);
745
1304
  return sa.reduce(
746
- (carry, a2) => sb.reduce(
747
- (carry2, b2) => carry2 > 0 ? Math.min(
1305
+ (carry, a3) => sb.reduce(
1306
+ (carry2, b3) => carry2 > 0 ? Math.min(
748
1307
  carry2,
749
- getDistanceOfLineToLine(a2, b2, calculation)
1308
+ getDistanceOfLineToLine(a3, b3, calculation)
750
1309
  ) : carry2,
751
1310
  carry
752
1311
  ),
753
1312
  Infinity
754
1313
  );
755
1314
  },
756
- PolygonPoint([exterior, ...interior], b, calculation) {
757
- if (isPointInRing(b, exterior)) {
1315
+ PolygonPoint([exterior, ...interior], b2, calculation) {
1316
+ if (isPointInRing(b2, exterior)) {
758
1317
  const [excluded] = interior.filter(
759
- (ring) => isPointInRing(b, ring)
1318
+ (ring) => isPointInRing(b2, ring)
760
1319
  );
761
- return excluded ? this.LineStringPoint(excluded, b, calculation) : 0;
1320
+ return excluded ? this.LineStringPoint(excluded, b2, calculation) : 0;
762
1321
  }
763
- return this.LineStringPoint(exterior, b, calculation);
1322
+ return this.LineStringPoint(exterior, b2, calculation);
764
1323
  },
765
- PolygonLineString(a, b, calculation) {
766
- const [exterior, ...interior] = a;
767
- const line = segments(b);
768
- const ring = b.some((b2) => isPointInRing(b2, exterior)) ? interior.find((a2) => b.every((b2) => isPointInRing(b2, a2))) : exterior;
1324
+ PolygonLineString(a2, b2, calculation) {
1325
+ const [exterior, ...interior] = a2;
1326
+ const line = segments(b2);
1327
+ const ring = b2.some((b3) => isPointInRing(b3, exterior)) ? interior.find((a3) => b2.every((b3) => isPointInRing(b3, a3))) : exterior;
769
1328
  return ring ? Math.min(
770
1329
  ...segments(ring).map(
771
- (a2) => Math.min(
1330
+ (a3) => Math.min(
772
1331
  ...line.map(
773
- (b2) => getDistanceOfLineToLine(a2, b2, calculation)
1332
+ (b3) => getDistanceOfLineToLine(a3, b3, calculation)
774
1333
  )
775
1334
  )
776
1335
  )
777
1336
  ) : 0;
778
1337
  },
779
- PolygonPolygon(a, b, calculation) {
1338
+ PolygonPolygon(a2, b2, calculation) {
780
1339
  return Math.min(
781
- this.PolygonLineString(a, b[0], calculation),
782
- this.PolygonLineString(b, a[0], calculation)
1340
+ this.PolygonLineString(a2, b2[0], calculation),
1341
+ this.PolygonLineString(b2, a2[0], calculation)
783
1342
  );
784
1343
  }
785
1344
  };
786
- function distance(a, b, calculation = "cartesian") {
1345
+ function cartesian2(a2, b2) {
1346
+ return distance(a2, b2, cartesian);
1347
+ }
1348
+ function haversine2(a2, b2) {
1349
+ return distance(a2, b2, haversine);
1350
+ }
1351
+ function vincenty2(a2, b2) {
1352
+ return distance(a2, b2, vincenty);
1353
+ }
1354
+ function karney2(a2, b2) {
1355
+ return distance(a2, b2, karney);
1356
+ }
1357
+ function distance(a2, b2, calculation = "haversine") {
787
1358
  const lookup = geometries;
788
1359
  return Math.min(
789
1360
  ...[
790
1361
  ...new IterablePairIterator(
791
- new SimpleGeometryIterator(a),
792
- new SimpleGeometryIterator(b)
1362
+ new SimpleGeometryIterator(a2),
1363
+ new SimpleGeometryIterator(b2)
793
1364
  )
794
- ].map(([a2, b2]) => {
795
- return a2.type + b2.type in lookup ? lookup[a2.type + b2.type](
796
- a2.coordinates,
797
- b2.coordinates,
1365
+ ].map(([a3, b3]) => {
1366
+ return a3.type + b3.type in lookup ? lookup[a3.type + b3.type](
1367
+ a3.coordinates,
1368
+ b3.coordinates,
798
1369
  calculation
799
- ) : b2.type + a2.type in lookup ? lookup[b2.type + a2.type](
800
- b2.coordinates,
801
- a2.coordinates,
1370
+ ) : b3.type + a3.type in lookup ? lookup[b3.type + a3.type](
1371
+ b3.coordinates,
1372
+ a3.coordinates,
802
1373
  calculation
803
1374
  ) : Infinity;
804
1375
  })
@@ -807,37 +1378,37 @@ var GeoJSON = (() => {
807
1378
 
808
1379
  // source/Domain/Utility/Intersect.ts
809
1380
  var geometries2 = {
810
- PointPoint(a, b) {
811
- return a.length >= 2 && b.length >= 2 && a.slice(0, 2).every((v, i) => v === b[i]);
1381
+ PointPoint(a2, b2) {
1382
+ return a2.length >= 2 && b2.length >= 2 && a2.slice(0, 2).every((v, i) => v === b2[i]);
812
1383
  },
813
- LineStringPoint(a, b) {
814
- return a.some((a2) => this.PointPoint(a2, b)) || segments(a).some((line) => isPointOnLine(b, line));
1384
+ LineStringPoint(a2, b2) {
1385
+ return a2.some((a3) => this.PointPoint(a3, b2)) || segments(a2).some((line) => isPointOnLine(b2, line));
815
1386
  },
816
- LineStringLineString(a, b) {
817
- const lines = segments(b);
818
- return segments(a).some(
819
- (a2) => lines.some((b2) => isLinesCrossing(a2, b2))
1387
+ LineStringLineString(a2, b2) {
1388
+ const lines = segments(b2);
1389
+ return segments(a2).some(
1390
+ (a3) => lines.some((b3) => isLinesCrossing(a3, b3))
820
1391
  );
821
1392
  },
822
- PolygonPoint([exterior, ...interior], b) {
823
- return (this.LineStringPoint(exterior, b) || isPointInRing(b, exterior)) && (!interior.length || interior.every((ring) => !isPointInRing(b, ring)));
1393
+ PolygonPoint([exterior, ...interior], b2) {
1394
+ return (this.LineStringPoint(exterior, b2) || isPointInRing(b2, exterior)) && (!interior.length || interior.every((ring) => !isPointInRing(b2, ring)));
824
1395
  },
825
- PolygonLineString(a, b) {
826
- return a.some((ring) => this.LineStringLineString(ring, b)) || b.some((point) => this.PolygonPoint(a, point));
1396
+ PolygonLineString(a2, b2) {
1397
+ return a2.some((ring) => this.LineStringLineString(ring, b2)) || b2.some((point) => this.PolygonPoint(a2, point));
827
1398
  },
828
- PolygonPolygon(a, b) {
829
- return b.some(
830
- (b1) => this.PolygonLineString(a, b1) || b1.some((b2) => this.PolygonPoint(a, b2))
831
- ) || a.some(
832
- (a1) => this.PolygonLineString(b, a1) || a1.some((a2) => this.PolygonPoint(b, a2))
1399
+ PolygonPolygon(a2, b2) {
1400
+ return b2.some(
1401
+ (b1) => this.PolygonLineString(a2, b1) || b1.some((b22) => this.PolygonPoint(a2, b22))
1402
+ ) || a2.some(
1403
+ (a1) => this.PolygonLineString(b2, a1) || a1.some((a22) => this.PolygonPoint(b2, a22))
833
1404
  );
834
1405
  }
835
1406
  };
836
- function intersect(a, b) {
1407
+ function intersect(a2, b2) {
837
1408
  const lookup = geometries2;
838
1409
  for (const [itA, itB] of new IterablePairIterator(
839
- new SimpleGeometryIterator(a),
840
- new SimpleGeometryIterator(b)
1410
+ new SimpleGeometryIterator(a2),
1411
+ new SimpleGeometryIterator(b2)
841
1412
  )) {
842
1413
  if (itA.type + itB.type in lookup && lookup[itA.type + itB.type](
843
1414
  itA.coordinates,