@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.
package/dist/main.js CHANGED
@@ -2,9 +2,9 @@ var __defProp = Object.defineProperty;
2
2
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
3
  var __getOwnPropNames = Object.getOwnPropertyNames;
4
4
  var __hasOwnProp = Object.prototype.hasOwnProperty;
5
- var __export = (target, all11) => {
6
- for (var name in all11)
7
- __defProp(target, name, { get: all11[name], enumerable: true });
5
+ var __export = (target, all2) => {
6
+ for (var name in all2)
7
+ __defProp(target, name, { get: all2[name], enumerable: true });
8
8
  };
9
9
  var __copyProps = (to, from, except, desc) => {
10
10
  if (from && typeof from === "object" || typeof from === "function") {
@@ -20,13 +20,16 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
20
20
  var main_exports = {};
21
21
  __export(main_exports, {
22
22
  SimpleGeometryIterator: () => SimpleGeometryIterator,
23
+ cartesian: () => cartesian2,
23
24
  distance: () => distance,
25
+ haversine: () => haversine2,
24
26
  intersect: () => intersect,
25
27
  isFeature: () => isFeature,
26
28
  isFeatureCollection: () => isFeatureCollection,
27
29
  isGeoJSON: () => isGeoJSON,
28
30
  isGeometry: () => isGeometry,
29
31
  isGeometryCollection: () => isGeometryCollection,
32
+ isGeometryPrimitive: () => isGeometryPrimitive,
30
33
  isLineString: () => isLineString,
31
34
  isMultiLineString: () => isMultiLineString,
32
35
  isMultiPoint: () => isMultiPoint,
@@ -39,23 +42,114 @@ __export(main_exports, {
39
42
  isStrictGeoJSON: () => isStrictGeoJSON,
40
43
  isStrictGeometry: () => isStrictGeometry,
41
44
  isStrictGeometryCollection: () => isStrictGeometryCollection,
45
+ isStrictGeometryPrimitive: () => isStrictGeometryPrimitive,
42
46
  isStrictLineString: () => isStrictLineString,
43
47
  isStrictMultiLineString: () => isStrictMultiLineString,
44
48
  isStrictMultiPoint: () => isStrictMultiPoint,
45
49
  isStrictMultiPolygon: () => isStrictMultiPolygon,
46
50
  isStrictPoint: () => isStrictPoint,
47
51
  isStrictPolygon: () => isStrictPolygon,
48
- isStrictPosition: () => isStrictPosition
52
+ isStrictPosition: () => isStrictPosition,
53
+ karney: () => karney2,
54
+ vincenty: () => vincenty2
49
55
  });
50
56
  module.exports = __toCommonJS(main_exports);
51
57
 
52
- // source/Domain/GeoJSON/Concept/Position.ts
53
- var import_guard3 = require("@konfirm/guard");
58
+ // node_modules/@konfirm/guard/dist/guard.es.js
59
+ var TypeMapper = class {
60
+ constructor(mapping = {}) {
61
+ this.mapping = Object.keys(mapping).map((key) => (value) => mapping[key](value) ? key : void 0).concat((value) => typeof value);
62
+ }
63
+ map(value) {
64
+ return this.mapping.reduce((carry, map) => carry || map(value), void 0);
65
+ }
66
+ };
67
+ var ValueMapper = class {
68
+ constructor(types2 = new TypeMapper(), mapping = {}) {
69
+ this.types = types2;
70
+ this.mapping = mapping;
71
+ }
72
+ map(value) {
73
+ const type = this.types.map(value);
74
+ const map = (value2) => this.map(value2);
75
+ return type in this.mapping ? this.mapping[type](value, map) : (value === null || value === void 0 ? void 0 : value.toString()) || "undefined";
76
+ }
77
+ };
78
+ var types = new TypeMapper({
79
+ date: (value) => value instanceof Date,
80
+ regexp: (value) => value instanceof RegExp,
81
+ array: (value) => Array.isArray(value),
82
+ null: (value) => value === null
83
+ });
84
+ var stringifier = new ValueMapper(types, {
85
+ string: (value) => value ? `"${value}"` : "EmptyString",
86
+ date: (value, map) => map(value.toISOString()),
87
+ object: (value, map) => {
88
+ const string = String(value);
89
+ if (/^\[([a-z]+) \1\]$/i.test(string)) {
90
+ const mapped = Object.keys(value).map((key) => `${key}:${map(value[key])}`);
91
+ return `{${mapped.join(",")}}`;
92
+ }
93
+ return string;
94
+ },
95
+ array: (value, map) => `[${value.map(map).join(",")}]`,
96
+ null: () => "NULL",
97
+ undefined: () => "Undefined",
98
+ function: (value) => {
99
+ const { constructor: { name: cname }, name } = value;
100
+ const [, async, generator, func] = cname.match(/^(async)?(generator)?(function)$/i);
101
+ const [, stype, sname] = value.toString().match(/^(?:async)?(?:[\s\*]+)?(class|function)?(?:[\s\*]+)?([a-z_]\w*)?\s*[\(\{]?/i);
102
+ const parts = [].concat(stype && !(name || sname) ? "anonymous" : []).concat(name && !stype && sname ? "shorthand" : []).concat(async || [], generator || []).concat(!(stype || sname) ? "arrow" : []).concat(stype || func).map((key) => key[0].toUpperCase() + key.slice(1));
103
+ return [parts.join("")].concat(name || []).join(" ");
104
+ }
105
+ });
106
+ function is(type) {
107
+ return (value) => typeof value === type;
108
+ }
109
+ function any(...checks) {
110
+ return (value) => checks.some((check) => check(value));
111
+ }
112
+ function all(...checks) {
113
+ return (value) => checks.every((check) => check(value));
114
+ }
115
+ function not(...checks) {
116
+ return (value) => checks.every((check) => !check(value));
117
+ }
118
+ var isArray = (value) => Array.isArray(value);
119
+ var isBigInt = is("bigint");
120
+ var isBoolean = is("boolean");
121
+ var isFunction = is("function");
122
+ var isNULL = (value) => value === null;
123
+ var isNumber = is("number");
124
+ var isObject = all(not(isArray), not(isNULL), is("object"));
125
+ var isString = is("string");
126
+ var isSymbol = is("symbol");
127
+ var isUndefined = is("undefined");
128
+ function isArrayOfType(...validators) {
129
+ const check = all(...validators);
130
+ return all(isArray, (value) => value.every(check));
131
+ }
132
+ function isArrayOfSize(min, max = Infinity) {
133
+ return all(isArray, (value) => value.length >= min && value.length <= max);
134
+ }
135
+ function isKey(key) {
136
+ return all(isObject, (value) => key in value);
137
+ }
138
+ function isKeyOfType(key, ...validators) {
139
+ return all(isKey(key), (value) => validators.every((check) => check(value[key])));
140
+ }
141
+ function isOptionalKeyOfType(key, ...validators) {
142
+ return any(all(isObject, not(isKey(key))), isKeyOfType(key, ...validators));
143
+ }
144
+ function isStructure(struct, ...options) {
145
+ const optional = options.reduce((carry, key) => carry.concat(key), []);
146
+ const validators = Object.keys(struct).map((key) => (optional.includes(key) ? isOptionalKeyOfType : isKeyOfType)(key, struct[key]));
147
+ return all(isObject, ...validators);
148
+ }
54
149
 
55
150
  // source/Domain/Guards/Tuple.ts
56
- var import_guard = require("@konfirm/guard");
57
151
  function isTuple(...rules) {
58
- return (value) => (0, import_guard.isArray)(value) && value.length === rules.length && rules.every((rule, index) => rule(value[index]));
152
+ return (value) => isArray(value) && value.length === rules.length && rules.every((rule, index) => rule(value[index]));
59
153
  }
60
154
 
61
155
  // source/Domain/Constants.ts
@@ -66,13 +160,12 @@ var EARTH_FLATTENING = 298.257223563;
66
160
  var GPS_SATELLITE_ORBIT = 2018e4;
67
161
 
68
162
  // source/Domain/Guards/Number.ts
69
- var import_guard2 = require("@konfirm/guard");
70
163
  function isNumberValue(value) {
71
- return (0, import_guard2.isNumber)(value) && Number.isFinite(value);
164
+ return isNumber(value) && Number.isFinite(value);
72
165
  }
73
- function isNumberBetween(a, b = Infinity) {
74
- const min = Math.min(a, b);
75
- 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);
76
169
  return (value) => isNumberValue(value) && value >= min && value <= max;
77
170
  }
78
171
 
@@ -98,24 +191,17 @@ function isLongitude(value) {
98
191
  var isStrictLongitude = isNumberBetween(-180, 180);
99
192
 
100
193
  // source/Domain/GeoJSON/Concept/Position.ts
101
- var isPosition = (0, import_guard3.any)(
194
+ var isPosition = any(
102
195
  isTuple(isLongitude, isLatitude),
103
196
  isTuple(isLongitude, isLatitude, isAltitude)
104
197
  );
105
- var isStrictPosition = (0, import_guard3.any)(
198
+ var isStrictPosition = any(
106
199
  isTuple(isStrictLongitude, isStrictLatitude),
107
200
  isTuple(isStrictLongitude, isStrictLatitude, isStrictAltitude)
108
201
  );
109
202
 
110
- // source/Domain/GeoJSON/Feature.ts
111
- var import_guard17 = require("@konfirm/guard");
112
-
113
- // source/Domain/GeoJSON/Concept/GeoJSONObject.ts
114
- var import_guard5 = require("@konfirm/guard");
115
-
116
203
  // source/Domain/GeoJSON/Concept/BoundingBox.ts
117
- var import_guard4 = require("@konfirm/guard");
118
- var isBoundingBoxWithAltitude = (0, import_guard4.all)(
204
+ var isBoundingBoxWithAltitude = all(
119
205
  isTuple(
120
206
  isLongitude,
121
207
  isLatitude,
@@ -124,18 +210,18 @@ var isBoundingBoxWithAltitude = (0, import_guard4.all)(
124
210
  isLatitude,
125
211
  isAltitude
126
212
  ),
127
- ([, s, , , n]) => s <= n
213
+ ([, s, , , n2]) => s <= n2
128
214
  );
129
- var isBoundingBoxWithoutAltitude = (0, import_guard4.all)(
215
+ var isBoundingBoxWithoutAltitude = all(
130
216
  isTuple(isLongitude, isLatitude, isLongitude, isLatitude),
131
- ([, s, , n]) => s <= n
217
+ ([, s, , n2]) => s <= n2
132
218
  );
133
- var isBoundingBox = (0, import_guard4.any)(
219
+ var isBoundingBox = any(
134
220
  isBoundingBoxWithAltitude,
135
221
  isBoundingBoxWithoutAltitude
136
222
  );
137
- var isStrictBoundingBox = (0, import_guard4.any)(
138
- (0, import_guard4.all)(
223
+ var isStrictBoundingBox = any(
224
+ all(
139
225
  isTuple(
140
226
  isStrictLongitude,
141
227
  isStrictLatitude,
@@ -146,7 +232,7 @@ var isStrictBoundingBox = (0, import_guard4.any)(
146
232
  ),
147
233
  isBoundingBoxWithAltitude
148
234
  ),
149
- (0, import_guard4.all)(
235
+ all(
150
236
  isTuple(
151
237
  isStrictLongitude,
152
238
  isStrictLatitude,
@@ -159,30 +245,23 @@ var isStrictBoundingBox = (0, import_guard4.any)(
159
245
 
160
246
  // source/Domain/GeoJSON/Concept/GeoJSONObject.ts
161
247
  function isGeoJSONObject(type) {
162
- return (0, import_guard5.isStructure)(
248
+ return isStructure(
163
249
  {
164
- type: (0, import_guard5.all)(import_guard5.isString, (value) => value === type),
250
+ type: all(isString, (value) => value === type),
165
251
  bbox: isBoundingBox
166
252
  },
167
253
  "bbox"
168
254
  );
169
255
  }
170
256
 
171
- // source/Domain/GeoJSON/Geometry.ts
172
- var import_guard15 = require("@konfirm/guard");
173
-
174
257
  // source/Domain/GeoJSON/GeometryObject.ts
175
- var import_guard6 = require("@konfirm/guard");
176
258
  function isGeometryObject(type, isCoordinates) {
177
- return (0, import_guard6.all)(
259
+ return all(
178
260
  isGeoJSONObject(type),
179
- (0, import_guard6.isKeyOfType)("coordinates", isCoordinates)
261
+ isKeyOfType("coordinates", isCoordinates)
180
262
  );
181
263
  }
182
264
 
183
- // source/Domain/GeoJSON/Geometry/MultiPoint.ts
184
- var import_guard7 = require("@konfirm/guard");
185
-
186
265
  // source/Domain/GeoJSON/Geometry/Point.ts
187
266
  var isPointCoordinates = isPosition;
188
267
  var isPoint = isGeometryObject(
@@ -196,12 +275,12 @@ var isStrictPoint = isGeometryObject(
196
275
  );
197
276
 
198
277
  // source/Domain/GeoJSON/Geometry/MultiPoint.ts
199
- var isMultiPointCoordinates = (0, import_guard7.isArrayOfType)(isPointCoordinates);
278
+ var isMultiPointCoordinates = isArrayOfType(isPointCoordinates);
200
279
  var isMultiPoint = isGeometryObject(
201
280
  "MultiPoint",
202
281
  isMultiPointCoordinates
203
282
  );
204
- var isStrictMultiPointCoordinates = (0, import_guard7.isArrayOfType)(isStrictPointCoordinates);
283
+ var isStrictMultiPointCoordinates = isArrayOfType(isStrictPointCoordinates);
205
284
  var isStrictMultiPoint = isGeometryObject(
206
285
  "MultiPoint",
207
286
  isStrictMultiPointCoordinates
@@ -217,15 +296,14 @@ var isStrictLineStringCoordinates = isStrictMultiPointCoordinates;
217
296
  var isStrictLineString = isGeometryObject("LineString", isStrictLineStringCoordinates);
218
297
 
219
298
  // source/Domain/GeoJSON/Geometry/MultiLineString.ts
220
- var import_guard8 = require("@konfirm/guard");
221
- var isMultiLineStringCoordinates = (0, import_guard8.isArrayOfType)(
299
+ var isMultiLineStringCoordinates = isArrayOfType(
222
300
  isLineStringCoordinates
223
301
  );
224
302
  var isMultiLineString = isGeometryObject(
225
303
  "MultiLineString",
226
304
  isMultiLineStringCoordinates
227
305
  );
228
- var isStrictMultiLineStringCoordinates = (0, import_guard8.isArrayOfType)(
306
+ var isStrictMultiLineStringCoordinates = isArrayOfType(
229
307
  isStrictLineStringCoordinates
230
308
  );
231
309
  var isStrictMultiLineString = isGeometryObject(
@@ -233,69 +311,57 @@ var isStrictMultiLineString = isGeometryObject(
233
311
  isStrictMultiLineStringCoordinates
234
312
  );
235
313
 
236
- // source/Domain/GeoJSON/Geometry/MultiPolygon.ts
237
- var import_guard14 = require("@konfirm/guard");
238
-
239
- // source/Domain/GeoJSON/Geometry/Polygon.ts
240
- var import_guard13 = require("@konfirm/guard");
241
-
242
- // source/Domain/GeoJSON/Concept/ExteriorRing.ts
243
- var import_guard11 = require("@konfirm/guard");
244
-
245
314
  // source/Domain/Utility/Winding.ts
246
- var import_guard9 = require("@konfirm/guard");
247
- function winding(positions2) {
248
- return positions2.reduce((carry, [x, y], i, a) => {
249
- const [nx, ny] = a[(i + 1) % a.length];
250
- 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);
251
319
  }, 0);
252
320
  }
253
- var isPositionArray = (0, import_guard9.isArrayOfType)(isPosition);
321
+ var isPositionArray = isArrayOfType(isPosition);
254
322
  function isClockwiseWinding(value) {
255
- return isPositionArray(value) && winding(value) <= 0;
323
+ return isPositionArray(value) && shoelace(value) <= 0;
256
324
  }
257
325
  function isCounterClockwiseWinding(value) {
258
- return isPositionArray(value) && winding(value) >= 0;
326
+ return isPositionArray(value) && shoelace(value) >= 0;
259
327
  }
260
328
 
261
329
  // source/Domain/GeoJSON/Concept/LinearRing.ts
262
- var import_guard10 = require("@konfirm/guard");
263
- var isLinearRing = (0, import_guard10.all)(
264
- (0, import_guard10.isArrayOfType)(isPosition),
265
- (0, import_guard10.isArrayOfSize)(4),
330
+ var isLinearRing = all(
331
+ isArrayOfType(isPosition),
332
+ isArrayOfSize(4),
266
333
  (value) => value[value.length - 1].every((v, i) => v === value[0][i])
267
334
  );
268
- var isStrictLinearRing = (0, import_guard10.all)(
269
- (0, import_guard10.isArrayOfType)(isStrictPosition),
270
- (0, import_guard10.isArrayOfSize)(4),
335
+ var isStrictLinearRing = all(
336
+ isArrayOfType(isStrictPosition),
337
+ isArrayOfSize(4),
271
338
  (value) => value[value.length - 1].every((v, i) => v === value[0][i])
272
339
  );
273
340
 
274
341
  // source/Domain/GeoJSON/Concept/ExteriorRing.ts
275
- var isExteriorRing = (0, import_guard11.all)(isLinearRing);
276
- var isStrictExteriorRing = (0, import_guard11.all)(
342
+ var isExteriorRing = all(isLinearRing);
343
+ var isStrictExteriorRing = all(
277
344
  isStrictLinearRing,
278
345
  isCounterClockwiseWinding
279
346
  );
280
347
 
281
348
  // source/Domain/GeoJSON/Concept/InteriorRing.ts
282
- var import_guard12 = require("@konfirm/guard");
283
- var isInteriorRing = (0, import_guard12.all)(isLinearRing);
284
- var isStrictInteriorRing = (0, import_guard12.all)(
349
+ var isInteriorRing = all(isLinearRing);
350
+ var isStrictInteriorRing = all(
285
351
  isStrictLinearRing,
286
352
  isClockwiseWinding
287
353
  );
288
354
 
289
355
  // source/Domain/GeoJSON/Geometry/Polygon.ts
290
- var isPolygonCoordinates = (0, import_guard13.all)((0, import_guard13.isArrayOfType)(isLinearRing));
356
+ var isPolygonCoordinates = all(isArrayOfType(isLinearRing));
291
357
  var isPolygon = isGeometryObject(
292
358
  "Polygon",
293
359
  isPolygonCoordinates
294
360
  );
295
- var isStrictPolygonCoordinates = (0, import_guard13.all)(
296
- (0, import_guard13.isArrayOfType)(isStrictLinearRing),
297
- (value) => isExteriorRing(value[0]),
298
- (value) => value.slice(1).every(isInteriorRing)
361
+ var isStrictPolygonCoordinates = all(
362
+ isArrayOfType(isStrictLinearRing),
363
+ (value) => isStrictExteriorRing(value[0]),
364
+ (value) => value.slice(1).every(isStrictInteriorRing)
299
365
  );
300
366
  var isStrictPolygon = isGeometryObject(
301
367
  "Polygon",
@@ -303,12 +369,12 @@ var isStrictPolygon = isGeometryObject(
303
369
  );
304
370
 
305
371
  // source/Domain/GeoJSON/Geometry/MultiPolygon.ts
306
- var isMultiPolygonCoordinates = (0, import_guard14.isArrayOfType)(isPolygonCoordinates);
372
+ var isMultiPolygonCoordinates = isArrayOfType(isPolygonCoordinates);
307
373
  var isMultiPolygon = isGeometryObject(
308
374
  "MultiPolygon",
309
375
  isMultiPolygonCoordinates
310
376
  );
311
- var isStrictMultiPolygonCoordinates = (0, import_guard14.isArrayOfType)(
377
+ var isStrictMultiPolygonCoordinates = isArrayOfType(
312
378
  isStrictPolygonCoordinates
313
379
  );
314
380
  var isStrictMultiPolygon = isGeometryObject(
@@ -317,7 +383,7 @@ var isStrictMultiPolygon = isGeometryObject(
317
383
  );
318
384
 
319
385
  // source/Domain/GeoJSON/Geometry.ts
320
- var isGeometry = (0, import_guard15.any)(
386
+ var isGeometryPrimitive = any(
321
387
  isPoint,
322
388
  isMultiPoint,
323
389
  isLineString,
@@ -325,7 +391,7 @@ var isGeometry = (0, import_guard15.any)(
325
391
  isPolygon,
326
392
  isMultiPolygon
327
393
  );
328
- var isStrictGeometry = (0, import_guard15.any)(
394
+ var isStrictGeometryPrimitive = any(
329
395
  isStrictPoint,
330
396
  isStrictMultiPoint,
331
397
  isStrictLineString,
@@ -333,66 +399,77 @@ var isStrictGeometry = (0, import_guard15.any)(
333
399
  isStrictPolygon,
334
400
  isStrictMultiPolygon
335
401
  );
336
-
337
- // source/Domain/GeoJSON/GeometryCollection.ts
338
- var import_guard16 = require("@konfirm/guard");
339
- var isGeometryCollectionObject = (0, import_guard16.all)(
402
+ var isGeometry = any(
403
+ isGeometryPrimitive,
404
+ isGeometryCollection
405
+ );
406
+ var isStrictGeometry = any(
407
+ isStrictGeometryPrimitive,
408
+ isStrictGeometryCollection
409
+ );
410
+ var isGeometryCollectionObject = all(
340
411
  isGeoJSONObject("GeometryCollection"),
341
- (0, import_guard16.isKeyOfType)(
342
- "geometries",
343
- (0, import_guard16.isArrayOfType)((0, import_guard16.any)(isGeometry, isGeometryCollection))
344
- )
412
+ isKeyOfType("geometries", isArrayOfType(isGeometry))
345
413
  );
346
- var isStrictGeometryCollectionObject = (0, import_guard16.all)(
414
+ var isStrictGeometryCollectionObject = all(
347
415
  isGeoJSONObject("GeometryCollection"),
348
- (0, import_guard16.isKeyOfType)(
349
- "geometries",
350
- (0, import_guard16.isArrayOfType)((0, import_guard16.any)(isStrictGeometry, isStrictGeometryCollection))
351
- )
416
+ isKeyOfType("geometries", isArrayOfType(isStrictGeometry))
352
417
  );
353
- function isGeometryCollection(value) {
354
- return isGeometryCollectionObject(value);
418
+ function isGeometryCollection(value, isG = isGeometryPrimitive) {
419
+ return isGeometryCollectionObject(value) && value.geometries.every((g) => isG(g) || isGeometryCollection(g, isG));
355
420
  }
356
- function isStrictGeometryCollection(value) {
357
- return isStrictGeometryCollectionObject(value);
421
+ function isStrictGeometryCollection(value, isG = isStrictGeometryPrimitive) {
422
+ return isStrictGeometryCollectionObject(value) && value.geometries.every(
423
+ (g) => isG(g) || isStrictGeometryCollection(g, isG)
424
+ );
358
425
  }
359
426
 
360
427
  // source/Domain/GeoJSON/Feature.ts
361
- var isFeature = (0, import_guard17.all)(
428
+ var isFeatureObject = all(
362
429
  isGeoJSONObject("Feature"),
363
- (0, import_guard17.isStructure)({
364
- geometry: (0, import_guard17.any)(isGeometry, isGeometryCollection),
365
- properties: (0, import_guard17.any)(import_guard17.isNULL, import_guard17.isObject)
430
+ isStructure({
431
+ geometry: any(isNULL, isGeometry),
432
+ properties: any(isNULL, isObject)
366
433
  })
367
434
  );
368
- var isStrictFeature = (0, import_guard17.all)(
435
+ var isStrictFeatureObject = all(
369
436
  isGeoJSONObject("Feature"),
370
- (0, import_guard17.isStructure)({
371
- geometry: (0, import_guard17.any)(isStrictGeometry, isStrictGeometryCollection),
372
- properties: (0, import_guard17.any)(import_guard17.isNULL, import_guard17.isObject)
437
+ isStructure({
438
+ geometry: any(isNULL, isStrictGeometry),
439
+ properties: any(isNULL, isObject)
373
440
  })
374
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
+ }
375
448
 
376
449
  // source/Domain/GeoJSON/FeatureCollection.ts
377
- var import_guard18 = require("@konfirm/guard");
378
- var isFeatureCollection = (0, import_guard18.all)(
450
+ var isFeatureCollectionObject = all(
379
451
  isGeoJSONObject("FeatureCollection"),
380
- (0, import_guard18.isKeyOfType)("features", (0, import_guard18.isArrayOfType)(isFeature))
452
+ isKeyOfType("features", isArrayOfType(isFeature))
381
453
  );
382
- var isStrictFeatureCollection = (0, import_guard18.all)(
454
+ var isStrictFeatureCollectionObject = all(
383
455
  isGeoJSONObject("FeatureCollection"),
384
- (0, import_guard18.isKeyOfType)("features", (0, import_guard18.isArrayOfType)(isStrictFeature))
456
+ isKeyOfType("features", isArrayOfType(isStrictFeature))
385
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
+ }
386
464
 
387
465
  // source/Domain/GeoJSON/GeoJSON.ts
388
- var import_guard19 = require("@konfirm/guard");
389
- var isGeoJSON = (0, import_guard19.any)(
466
+ var isGeoJSON = any(
390
467
  isGeometry,
391
468
  isGeometryCollection,
392
469
  isFeature,
393
470
  isFeatureCollection
394
471
  );
395
- var isStrictGeoJSON = (0, import_guard19.any)(
472
+ var isStrictGeoJSON = any(
396
473
  isStrictGeometry,
397
474
  isStrictGeometryCollection,
398
475
  isStrictFeature,
@@ -434,11 +511,15 @@ var reducers = {
434
511
  }
435
512
  },
436
513
  *Feature({ geometry }, unwrap) {
437
- yield* unwrap(geometry);
514
+ if (geometry) {
515
+ yield* unwrap(geometry);
516
+ }
438
517
  },
439
518
  *FeatureCollection({ features }, unwrap) {
440
519
  for (const { geometry } of features) {
441
- yield* unwrap(geometry);
520
+ if (geometry) {
521
+ yield* unwrap(geometry);
522
+ }
442
523
  }
443
524
  }
444
525
  };
@@ -494,9 +575,9 @@ var IterablePairIterator = class {
494
575
  * @memberof IterablePairIterator
495
576
  */
496
577
  *[Symbol.iterator]() {
497
- for (const [a, b] of this.pairs(this.iterators)) {
498
- for (const one of a) {
499
- 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) {
500
581
  yield [one, two];
501
582
  }
502
583
  }
@@ -512,7 +593,7 @@ var IterablePairIterator = class {
512
593
  */
513
594
  pairs(source) {
514
595
  return source.flatMap(
515
- (a, i) => source.slice(i + 1).map((b) => [a, b])
596
+ (a2, i) => source.slice(i + 1).map((b2) => [a2, b2])
516
597
  );
517
598
  }
518
599
  };
@@ -544,70 +625,605 @@ function isWithinBox([lon, lat], [minLon, minLat, maxLon, maxLat]) {
544
625
  return lon >= minLon && lon <= maxLon && lat >= minLat && lat <= maxLat;
545
626
  }
546
627
 
547
- // 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);
548
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;
549
1161
  var \u03C0 = Math.PI;
550
1162
  function constrain(value, min, max) {
551
1163
  return Math.max(Math.min(value, max), min);
552
1164
  }
553
- function squared(n) {
554
- return n * n;
555
- }
556
- function rad(n) {
557
- return n * D2R;
1165
+ function rad(n2) {
1166
+ return n2 * D2R2;
558
1167
  }
559
1168
  var EARTH_RADIUS_MAJOR_SQUARED = squared(EARTH_RADIUS_MAJOR);
560
1169
  var EARTH_RADIUS_MINOR_SQUARED = squared(EARTH_RADIUS_MINOR);
561
1170
  var EARTH_RADIUS_FACTOR = (EARTH_RADIUS_MAJOR_SQUARED - EARTH_RADIUS_MINOR_SQUARED) / EARTH_RADIUS_MINOR_SQUARED;
562
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
+ }
563
1222
  var PointToPoint = {
564
- cartesian([\u03BBa, \u03C6a], [\u03BBb, \u03C6b]) {
565
- return EARTH_RADIUS * rad(Math.sqrt(squared(\u03BBb - \u03BBa) + squared(\u03C6b - \u03C6a)));
566
- },
567
- haversine([\u03BBa, \u03C6a], [\u03BBb, \u03C6b]) {
568
- const \u0394 = squared(Math.sin(rad(\u03C6b - \u03C6a) / 2)) + Math.cos(rad(\u03C6a)) * Math.cos(rad(\u03C6b)) * squared(Math.sin(rad(\u03BBb - \u03BBa) / 2));
569
- return EARTH_RADIUS * Math.atan2(Math.sqrt(\u0394), Math.sqrt(1 - \u0394)) * 2;
570
- },
571
- vincenty(...points) {
572
- const [[\u03BB1, \u03C61], [\u03BB2, \u03C62]] = points.map(
573
- (p) => p.map(rad)
574
- );
575
- const L = \u03BB2 - \u03BB1;
576
- const tanU1 = (1 - EARTH_INVERSE_FLATTENING) * Math.tan(\u03C61), cosU1 = 1 / Math.sqrt(1 + tanU1 * tanU1), sinU1 = tanU1 * cosU1;
577
- const tanU2 = (1 - EARTH_INVERSE_FLATTENING) * Math.tan(\u03C62), cosU2 = 1 / Math.sqrt(1 + tanU2 * tanU2), sinU2 = tanU2 * cosU2;
578
- const antipodal = Math.abs(L) > \u03C0 / 2 || Math.abs(\u03C62 - \u03C61) > \u03C0 / 2;
579
- let \u03BB = L;
580
- let sin\u03BB = null;
581
- let cos\u03BB = null;
582
- let \u03C3 = antipodal ? \u03C0 : 0;
583
- let sin\u03C3 = 0;
584
- let cos\u03C3 = antipodal ? -1 : 1;
585
- let sinSq\u03C3 = null;
586
- let cos2\u03C3\u2098 = 1;
587
- let cosSq\u03B1 = 1;
588
- let \u03BB\u02B9 = null;
589
- let iterations = 0;
590
- do {
591
- sin\u03BB = Math.sin(\u03BB);
592
- cos\u03BB = Math.cos(\u03BB);
593
- sinSq\u03C3 = (cosU2 * sin\u03BB) ** 2 + (cosU1 * sinU2 - sinU1 * cosU2 * cos\u03BB) ** 2;
594
- if (Math.abs(sinSq\u03C3) < 1e-24) break;
595
- sin\u03C3 = Math.sqrt(sinSq\u03C3);
596
- cos\u03C3 = sinU1 * sinU2 + cosU1 * cosU2 * cos\u03BB;
597
- \u03C3 = Math.atan2(sin\u03C3, cos\u03C3);
598
- const sin\u03B1 = cosU1 * cosU2 * sin\u03BB / sin\u03C3;
599
- cosSq\u03B1 = 1 - sin\u03B1 * sin\u03B1;
600
- cos2\u03C3\u2098 = cosSq\u03B1 !== 0 ? cos\u03C3 - 2 * sinU1 * sinU2 / cosSq\u03B1 : 0;
601
- const C = EARTH_INVERSE_FLATTENING / 16 * cosSq\u03B1 * (4 + EARTH_INVERSE_FLATTENING * (4 - 3 * cosSq\u03B1));
602
- \u03BB\u02B9 = \u03BB;
603
- \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)));
604
- } while (Math.abs(\u03BB - \u03BB\u02B9) > 1e-12 && ++iterations < 1e3);
605
- const uSq = cosSq\u03B1 * EARTH_RADIUS_FACTOR;
606
- const A = 1 + uSq / 16384 * (4096 + uSq * (-768 + uSq * (320 - 175 * uSq)));
607
- const B = uSq / 1024 * (256 + uSq * (-128 + uSq * (74 - 47 * uSq)));
608
- 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)));
609
- return EARTH_RADIUS_MINOR * A * (\u03C3 - \u0394\u03C3);
610
- }
1223
+ cartesian,
1224
+ haversine,
1225
+ vincenty,
1226
+ karney
611
1227
  };
612
1228
  function getClosestPointOnLineByPoint(point, line) {
613
1229
  const [[px, py], [ax, ay], [bx, by]] = [point, ...line];
@@ -620,10 +1236,10 @@ function getClosestPointOnLineByPoint(point, line) {
620
1236
  );
621
1237
  return t === 0 || t === 1 ? line[t] : [ax + abx * t, ay + aby * t];
622
1238
  }
623
- function getDistanceOfPointToPoint(a, b, calculation) {
1239
+ function getDistanceOfPointToPoint(a2, b2, calculation) {
624
1240
  const calc = typeof calculation === "function" ? calculation : PointToPoint[calculation];
625
1241
  if (typeof calc === "function") {
626
- return calc(a, b);
1242
+ return calc(a2, b2);
627
1243
  }
628
1244
  throw new Error(`Not a PointToPoint calculation function ${calculation}`);
629
1245
  }
@@ -634,15 +1250,15 @@ function getDistanceOfPointToLine(point, line, calculation) {
634
1250
  calculation
635
1251
  );
636
1252
  }
637
- function getDistanceOfLineToLine(a, b, calculation) {
638
- return isLinesCrossing(a, b) ? 0 : Math.min(
639
- ...a.map((a2) => getDistanceOfPointToLine(a2, b, calculation)),
640
- ...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))
641
1257
  );
642
1258
  }
643
- function isLinesCrossing(a, b) {
644
- const [[a1x, a1y], [a2x, a2y]] = a;
645
- 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;
646
1262
  const [s1x, s1y, s2x, s2y] = [a2x - a1x, a2y - a1y, b2x - b1x, b2y - b1y];
647
1263
  const s = (-s1y * (a1x - b1x) + s1x * (a1y - b1y)) / (-s2x * s1y + s1x * s2y);
648
1264
  const t = (s2x * (a1y - b1y) - s2y * (a1x - b1x)) / (-s2x * s1y + s1x * s2y);
@@ -656,13 +1272,13 @@ function isPointInRing(p, ring) {
656
1272
  return false;
657
1273
  }
658
1274
  const { length } = ring;
659
- const odd = ring.reduce((odd2, a, i) => {
660
- const b = ring[(length + i - 1) % length];
661
- 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(
662
- 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]
663
1279
  ) : odd2;
664
1280
  }, 0);
665
- 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]));
666
1282
  }
667
1283
 
668
1284
  // source/Domain/Utility/Segments.ts
@@ -672,76 +1288,88 @@ function segments(line) {
672
1288
 
673
1289
  // source/Domain/Utility/Distance.ts
674
1290
  var geometries = {
675
- PointPoint(a, b, calculation) {
676
- return getDistanceOfPointToPoint(a, b, calculation);
1291
+ PointPoint(a2, b2, calculation) {
1292
+ return getDistanceOfPointToPoint(a2, b2, calculation);
677
1293
  },
678
- LineStringPoint(a, b, calculation) {
1294
+ LineStringPoint(a2, b2, calculation) {
679
1295
  return Math.min(
680
- ...segments(a).map(
681
- (line) => getDistanceOfPointToLine(b, line, calculation)
1296
+ ...segments(a2).map(
1297
+ (line) => getDistanceOfPointToLine(b2, line, calculation)
682
1298
  )
683
1299
  );
684
1300
  },
685
- LineStringLineString(a, b, calculation) {
686
- const sa = segments(a);
687
- const sb = segments(b);
1301
+ LineStringLineString(a2, b2, calculation) {
1302
+ const sa = segments(a2);
1303
+ const sb = segments(b2);
688
1304
  return sa.reduce(
689
- (carry, a2) => sb.reduce(
690
- (carry2, b2) => carry2 > 0 ? Math.min(
1305
+ (carry, a3) => sb.reduce(
1306
+ (carry2, b3) => carry2 > 0 ? Math.min(
691
1307
  carry2,
692
- getDistanceOfLineToLine(a2, b2, calculation)
1308
+ getDistanceOfLineToLine(a3, b3, calculation)
693
1309
  ) : carry2,
694
1310
  carry
695
1311
  ),
696
1312
  Infinity
697
1313
  );
698
1314
  },
699
- PolygonPoint([exterior, ...interior], b, calculation) {
700
- if (isPointInRing(b, exterior)) {
1315
+ PolygonPoint([exterior, ...interior], b2, calculation) {
1316
+ if (isPointInRing(b2, exterior)) {
701
1317
  const [excluded] = interior.filter(
702
- (ring) => isPointInRing(b, ring)
1318
+ (ring) => isPointInRing(b2, ring)
703
1319
  );
704
- return excluded ? this.LineStringPoint(excluded, b, calculation) : 0;
1320
+ return excluded ? this.LineStringPoint(excluded, b2, calculation) : 0;
705
1321
  }
706
- return this.LineStringPoint(exterior, b, calculation);
1322
+ return this.LineStringPoint(exterior, b2, calculation);
707
1323
  },
708
- PolygonLineString(a, b, calculation) {
709
- const [exterior, ...interior] = a;
710
- const line = segments(b);
711
- 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;
712
1328
  return ring ? Math.min(
713
1329
  ...segments(ring).map(
714
- (a2) => Math.min(
1330
+ (a3) => Math.min(
715
1331
  ...line.map(
716
- (b2) => getDistanceOfLineToLine(a2, b2, calculation)
1332
+ (b3) => getDistanceOfLineToLine(a3, b3, calculation)
717
1333
  )
718
1334
  )
719
1335
  )
720
1336
  ) : 0;
721
1337
  },
722
- PolygonPolygon(a, b, calculation) {
1338
+ PolygonPolygon(a2, b2, calculation) {
723
1339
  return Math.min(
724
- this.PolygonLineString(a, b[0], calculation),
725
- this.PolygonLineString(b, a[0], calculation)
1340
+ this.PolygonLineString(a2, b2[0], calculation),
1341
+ this.PolygonLineString(b2, a2[0], calculation)
726
1342
  );
727
1343
  }
728
1344
  };
729
- 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") {
730
1358
  const lookup = geometries;
731
1359
  return Math.min(
732
1360
  ...[
733
1361
  ...new IterablePairIterator(
734
- new SimpleGeometryIterator(a),
735
- new SimpleGeometryIterator(b)
1362
+ new SimpleGeometryIterator(a2),
1363
+ new SimpleGeometryIterator(b2)
736
1364
  )
737
- ].map(([a2, b2]) => {
738
- return a2.type + b2.type in lookup ? lookup[a2.type + b2.type](
739
- a2.coordinates,
740
- 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,
741
1369
  calculation
742
- ) : b2.type + a2.type in lookup ? lookup[b2.type + a2.type](
743
- b2.coordinates,
744
- a2.coordinates,
1370
+ ) : b3.type + a3.type in lookup ? lookup[b3.type + a3.type](
1371
+ b3.coordinates,
1372
+ a3.coordinates,
745
1373
  calculation
746
1374
  ) : Infinity;
747
1375
  })
@@ -750,37 +1378,37 @@ function distance(a, b, calculation = "cartesian") {
750
1378
 
751
1379
  // source/Domain/Utility/Intersect.ts
752
1380
  var geometries2 = {
753
- PointPoint(a, b) {
754
- 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]);
755
1383
  },
756
- LineStringPoint(a, b) {
757
- 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));
758
1386
  },
759
- LineStringLineString(a, b) {
760
- const lines = segments(b);
761
- return segments(a).some(
762
- (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))
763
1391
  );
764
1392
  },
765
- PolygonPoint([exterior, ...interior], b) {
766
- 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)));
767
1395
  },
768
- PolygonLineString(a, b) {
769
- 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));
770
1398
  },
771
- PolygonPolygon(a, b) {
772
- return b.some(
773
- (b1) => this.PolygonLineString(a, b1) || b1.some((b2) => this.PolygonPoint(a, b2))
774
- ) || a.some(
775
- (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))
776
1404
  );
777
1405
  }
778
1406
  };
779
- function intersect(a, b) {
1407
+ function intersect(a2, b2) {
780
1408
  const lookup = geometries2;
781
1409
  for (const [itA, itB] of new IterablePairIterator(
782
- new SimpleGeometryIterator(a),
783
- new SimpleGeometryIterator(b)
1410
+ new SimpleGeometryIterator(a2),
1411
+ new SimpleGeometryIterator(b2)
784
1412
  )) {
785
1413
  if (itA.type + itB.type in lookup && lookup[itA.type + itB.type](
786
1414
  itA.coordinates,
@@ -794,13 +1422,16 @@ function intersect(a, b) {
794
1422
  // Annotate the CommonJS export names for ESM import in node:
795
1423
  0 && (module.exports = {
796
1424
  SimpleGeometryIterator,
1425
+ cartesian,
797
1426
  distance,
1427
+ haversine,
798
1428
  intersect,
799
1429
  isFeature,
800
1430
  isFeatureCollection,
801
1431
  isGeoJSON,
802
1432
  isGeometry,
803
1433
  isGeometryCollection,
1434
+ isGeometryPrimitive,
804
1435
  isLineString,
805
1436
  isMultiLineString,
806
1437
  isMultiPoint,
@@ -813,12 +1444,15 @@ function intersect(a, b) {
813
1444
  isStrictGeoJSON,
814
1445
  isStrictGeometry,
815
1446
  isStrictGeometryCollection,
1447
+ isStrictGeometryPrimitive,
816
1448
  isStrictLineString,
817
1449
  isStrictMultiLineString,
818
1450
  isStrictMultiPoint,
819
1451
  isStrictMultiPolygon,
820
1452
  isStrictPoint,
821
1453
  isStrictPolygon,
822
- isStrictPosition
1454
+ isStrictPosition,
1455
+ karney,
1456
+ vincenty
823
1457
  });
824
1458
  //# sourceMappingURL=main.js.map