@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/README.md +195 -40
- package/dist/main.d.mts +27 -21
- package/dist/main.d.ts +27 -21
- package/dist/main.global.js +735 -164
- package/dist/main.global.js.map +1 -1
- package/dist/main.js +880 -246
- package/dist/main.js.map +1 -1
- package/dist/main.mjs +856 -228
- package/dist/main.mjs.map +1 -1
- package/package.json +6 -6
package/dist/main.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../source/main.ts","../source/Domain/GeoJSON/Concept/Position.ts","../source/Domain/Guards/Tuple.ts","../source/Domain/Constants.ts","../source/Domain/Guards/Number.ts","../source/Domain/GeoJSON/Concept/Altitude.ts","../source/Domain/GeoJSON/Concept/Latitude.ts","../source/Domain/GeoJSON/Concept/Longitude.ts","../source/Domain/GeoJSON/Feature.ts","../source/Domain/GeoJSON/Concept/GeoJSONObject.ts","../source/Domain/GeoJSON/Concept/BoundingBox.ts","../source/Domain/GeoJSON/Geometry.ts","../source/Domain/GeoJSON/GeometryObject.ts","../source/Domain/GeoJSON/Geometry/MultiPoint.ts","../source/Domain/GeoJSON/Geometry/Point.ts","../source/Domain/GeoJSON/Geometry/LineString.ts","../source/Domain/GeoJSON/Geometry/MultiLineString.ts","../source/Domain/GeoJSON/Geometry/MultiPolygon.ts","../source/Domain/GeoJSON/Geometry/Polygon.ts","../source/Domain/GeoJSON/Concept/ExteriorRing.ts","../source/Domain/Utility/Winding.ts","../source/Domain/GeoJSON/Concept/LinearRing.ts","../source/Domain/GeoJSON/Concept/InteriorRing.ts","../source/Domain/GeoJSON/GeometryCollection.ts","../source/Domain/GeoJSON/FeatureCollection.ts","../source/Domain/GeoJSON/GeoJSON.ts","../source/Domain/Iterator/SimpleGeometry.ts","../source/Domain/Iterator/IterablePair.ts","../source/Domain/Utility/Box.ts","../source/Domain/Utility/Calculate.ts","../source/Domain/Utility/Segments.ts","../source/Domain/Utility/Distance.ts","../source/Domain/Utility/Intersect.ts"],"sourcesContent":["// intersect and distance functions\n\n// the individual GeoJSON types and type guards\nexport {\n\tisPosition,\n\tisStrictPosition,\n\tPosition,\n} from './Domain/GeoJSON/Concept/Position';\nexport { Feature, isFeature, isStrictFeature } from './Domain/GeoJSON/Feature';\nexport {\n\tFeatureCollection,\n\tisFeatureCollection,\n\tisStrictFeatureCollection,\n} from './Domain/GeoJSON/FeatureCollection';\nexport { GeoJSON, isGeoJSON, isStrictGeoJSON } from './Domain/GeoJSON/GeoJSON';\nexport {\n\tGeometry,\n\tisGeometry,\n\tisStrictGeometry,\n} from './Domain/GeoJSON/Geometry';\nexport {\n\tisLineString,\n\tisStrictLineString,\n\tLineString,\n} from './Domain/GeoJSON/Geometry/LineString';\nexport {\n\tisMultiLineString,\n\tisStrictMultiLineString,\n\tMultiLineString,\n} from './Domain/GeoJSON/Geometry/MultiLineString';\nexport {\n\tisMultiPoint,\n\tisStrictMultiPoint,\n\tMultiPoint,\n} from './Domain/GeoJSON/Geometry/MultiPoint';\nexport {\n\tisMultiPolygon,\n\tisStrictMultiPolygon,\n\tMultiPolygon,\n} from './Domain/GeoJSON/Geometry/MultiPolygon';\nexport { isPoint, isStrictPoint, Point } from './Domain/GeoJSON/Geometry/Point';\nexport {\n\tisPolygon,\n\tisStrictPolygon,\n\tPolygon,\n} from './Domain/GeoJSON/Geometry/Polygon';\nexport {\n\tGeometryCollection,\n\tisGeometryCollection,\n\tisStrictGeometryCollection,\n} from './Domain/GeoJSON/GeometryCollection';\n// SimpleGeometryIterator\nexport { SimpleGeometryIterator } from './Domain/Iterator/SimpleGeometry';\nexport { distance } from './Domain/Utility/Distance';\nexport { intersect } from './Domain/Utility/Intersect';\n","import { any } from '@konfirm/guard';\nimport { isTuple } from '../../Guards/Tuple';\nimport { type Altitude, isAltitude, isStrictAltitude } from './Altitude';\nimport { isLatitude, isStrictLatitude, type Latitude } from './Latitude';\nimport { isLongitude, isStrictLongitude, type Longitude } from './Longitude';\n\nexport type Position = [Longitude, Latitude, Altitude?];\nexport const isPosition = any<Position>(\n\tisTuple(isLongitude, isLatitude),\n\tisTuple(isLongitude, isLatitude, isAltitude),\n);\nexport const isStrictPosition = any<Position>(\n\tisTuple(isStrictLongitude, isStrictLatitude),\n\tisTuple(isStrictLongitude, isStrictLatitude, isStrictAltitude),\n);\nexport function isEquivalentPosition(one: unknown, two: unknown): boolean {\n\treturn (\n\t\tisPosition(one) &&\n\t\tisPosition(two) &&\n\t\tone.length === two.length &&\n\t\tone.every((v, i) => v === two[i])\n\t);\n}\n","import { type Guard, isArray, type Validator } from '@konfirm/guard';\n\nexport function isTuple<T extends Array<unknown>>(\n\t...rules: Array<Validator>\n): Guard<T> {\n\treturn (value: unknown): value is T =>\n\t\tisArray(value) &&\n\t\tvalue.length === rules.length &&\n\t\trules.every((rule, index) => rule(value[index]));\n}\n","export const EARTH_RADIUS = 6_371_008.7714; // mean radius\nexport const EARTH_RADIUS_MAJOR = 6_378_137; // equatorial radius\nexport const EARTH_RADIUS_MINOR = 6_356_752.314_245; // semiminor axis\nexport const EARTH_FLATTENING = 298.257_223_563;\nexport const GPS_SATELLITE_ORBIT = 20_180_000;\n","import { type Guard, isNumber } from '@konfirm/guard';\n\nexport function isNumberValue<T extends number>(value: unknown): value is T {\n\treturn isNumber(value) && Number.isFinite(value);\n}\n\nexport function isNumberBetween<T extends number>(\n\ta: number,\n\tb: number = Infinity,\n): Guard<T> {\n\tconst min = Math.min(a, b);\n\tconst max = Math.max(a, b);\n\n\treturn (value: unknown): value is T =>\n\t\tisNumberValue(value) && value >= min && value <= max;\n}\n","import { EARTH_RADIUS, GPS_SATELLITE_ORBIT } from '../../Constants';\nimport { isNumberBetween, isNumberValue } from '../../Guards/Number';\n\nexport type Altitude = number;\nexport function isAltitude(value: unknown): value is Altitude {\n\treturn isNumberValue(value);\n}\n\nexport const isStrictAltitude = isNumberBetween<Altitude>(\n\t-EARTH_RADIUS,\n\tGPS_SATELLITE_ORBIT,\n);\n","import { isNumberBetween, isNumberValue } from '../../Guards/Number';\n\nexport type Latitude = number;\nexport function isLatitude(value: unknown): value is Latitude {\n\treturn isNumberValue(value);\n}\nexport const isStrictLatitude = isNumberBetween<Latitude>(-90, 90);\n","import { isNumberBetween, isNumberValue } from '../../Guards/Number';\n\nexport type Longitude = number;\nexport function isLongitude(value: unknown): value is Longitude {\n\treturn isNumberValue(value);\n}\nexport const isStrictLongitude = isNumberBetween<Longitude>(-180, 180);\n","import { all, any, isNULL, isObject, isStructure } from '@konfirm/guard';\nimport { type GeoJSONObject, isGeoJSONObject } from './Concept/GeoJSONObject';\nimport { type Geometry, isGeometry, isStrictGeometry } from './Geometry';\nimport {\n\ttype GeometryCollection,\n\tisGeometryCollection,\n\tisStrictGeometryCollection,\n} from './GeometryCollection';\n\nexport type Feature = GeoJSONObject<{\n\ttype: 'Feature';\n\tgeometry: Geometry | GeometryCollection;\n\tproperties: { [key: string]: unknown } | null;\n}>;\nexport const isFeature = all<Feature>(\n\tisGeoJSONObject('Feature'),\n\tisStructure({\n\t\tgeometry: any(isGeometry, isGeometryCollection),\n\t\tproperties: any(isNULL, isObject),\n\t}),\n);\nexport const isStrictFeature = all<Feature>(\n\tisGeoJSONObject('Feature'),\n\tisStructure({\n\t\tgeometry: any(isStrictGeometry, isStrictGeometryCollection),\n\t\tproperties: any(isNULL, isObject),\n\t}),\n);\n","import { all, type Guard, isString, isStructure } from '@konfirm/guard';\nimport {\n\ttype BoundingBox,\n\tisBoundingBox,\n\tisStrictBoundingBox,\n} from './BoundingBox';\n\ntype GeoJSONBase = {\n\ttype: string;\n\tbbox?: BoundingBox;\n\t[key: string]: unknown;\n};\nexport type GeoJSONObject<T extends GeoJSONBase = GeoJSONBase> = GeoJSONBase &\n\tT;\nexport function isGeoJSONObject<T extends GeoJSONBase>(type: string): Guard<T> {\n\treturn isStructure<T>(\n\t\t{\n\t\t\ttype: all(isString, (value: unknown) => value === type),\n\t\t\tbbox: isBoundingBox,\n\t\t},\n\t\t'bbox',\n\t);\n}\nexport function isStrictGeoJSONObject<T extends GeoJSONBase>(\n\ttype: string,\n): Guard<T> {\n\treturn isStructure<T>(\n\t\t{\n\t\t\ttype: all(isString, (value: unknown) => value === type),\n\t\t\tbbox: isStrictBoundingBox,\n\t\t},\n\t\t'bbox',\n\t);\n}\n","import { all, any } from '@konfirm/guard';\nimport { isTuple } from '../../Guards/Tuple';\nimport { type Altitude, isAltitude, isStrictAltitude } from './Altitude';\nimport { isLatitude, isStrictLatitude, type Latitude } from './Latitude';\nimport { isLongitude, isStrictLongitude, type Longitude } from './Longitude';\n\nexport type BoundingBox =\n\t| [Longitude, Latitude, Altitude, Longitude, Latitude, Altitude]\n\t| [Longitude, Latitude, Longitude, Latitude];\nconst isBoundingBoxWithAltitude = all(\n\tisTuple(\n\t\tisLongitude,\n\t\tisLatitude,\n\t\tisAltitude,\n\t\tisLongitude,\n\t\tisLatitude,\n\t\tisAltitude,\n\t),\n\t([, s, , , n]) => s <= n,\n);\nconst isBoundingBoxWithoutAltitude = all(\n\tisTuple(isLongitude, isLatitude, isLongitude, isLatitude),\n\t([, s, , n]) => s <= n,\n);\nexport const isBoundingBox = any<BoundingBox>(\n\tisBoundingBoxWithAltitude,\n\tisBoundingBoxWithoutAltitude,\n);\nexport const isStrictBoundingBox = any<BoundingBox>(\n\tall(\n\t\tisTuple(\n\t\t\tisStrictLongitude,\n\t\t\tisStrictLatitude,\n\t\t\tisStrictAltitude,\n\t\t\tisStrictLongitude,\n\t\t\tisStrictLatitude,\n\t\t\tisStrictAltitude,\n\t\t),\n\t\tisBoundingBoxWithAltitude,\n\t),\n\tall(\n\t\tisTuple(\n\t\t\tisStrictLongitude,\n\t\t\tisStrictLatitude,\n\t\t\tisStrictLongitude,\n\t\t\tisStrictLatitude,\n\t\t),\n\t\tisBoundingBoxWithoutAltitude,\n\t),\n);\n","import { any } from '@konfirm/guard';\nimport {\n\tisLineString,\n\tisStrictLineString,\n\ttype LineString,\n} from './Geometry/LineString';\nimport {\n\tisMultiLineString,\n\tisStrictMultiLineString,\n\ttype MultiLineString,\n} from './Geometry/MultiLineString';\nimport {\n\tisMultiPoint,\n\tisStrictMultiPoint,\n\ttype MultiPoint,\n} from './Geometry/MultiPoint';\nimport {\n\tisMultiPolygon,\n\tisStrictMultiPolygon,\n\ttype MultiPolygon,\n} from './Geometry/MultiPolygon';\nimport { isPoint, isStrictPoint, type Point } from './Geometry/Point';\nimport { isPolygon, isStrictPolygon, type Polygon } from './Geometry/Polygon';\n\nexport type Geometry =\n\t| Point\n\t| MultiPoint\n\t| LineString\n\t| MultiLineString\n\t| Polygon\n\t| MultiPolygon;\nexport const isGeometry = any<Geometry>(\n\tisPoint,\n\tisMultiPoint,\n\tisLineString,\n\tisMultiLineString,\n\tisPolygon,\n\tisMultiPolygon,\n);\nexport const isStrictGeometry = any<Geometry>(\n\tisStrictPoint,\n\tisStrictMultiPoint,\n\tisStrictLineString,\n\tisStrictMultiLineString,\n\tisStrictPolygon,\n\tisStrictMultiPolygon,\n);\n","import { all, type Guard, isKeyOfType, type Validator } from '@konfirm/guard';\nimport { type GeoJSONObject, isGeoJSONObject } from './Concept/GeoJSONObject';\n\ntype GeometryBase = GeoJSONObject & {\n\tcoordinates: Array<unknown>;\n};\n\nexport type GeometryObject<T extends GeometryBase> = Omit<\n\tGeometryBase,\n\t'coordinates'\n> &\n\tT;\nexport type MultiGeometryObject<T extends GeometryBase> = GeometryObject<{\n\ttype: `Multi${T['type']}`;\n\tcoordinates: Array<T['coordinates']>;\n}>;\nexport function isGeometryObject<T extends GeometryBase>(\n\ttype: string,\n\tisCoordinates: Validator,\n): Guard<T> {\n\treturn all<T>(\n\t\tisGeoJSONObject(type),\n\t\tisKeyOfType('coordinates', isCoordinates),\n\t);\n}\n","import { type Guard, isArrayOfType } from '@konfirm/guard';\nimport { isGeometryObject, type MultiGeometryObject } from '../GeometryObject';\nimport {\n\tisPointCoordinates,\n\tisStrictPointCoordinates,\n\ttype Point,\n} from './Point';\n\nexport type MultiPoint = MultiGeometryObject<Point>;\nexport const isMultiPointCoordinates: Guard<MultiPoint['coordinates']> =\n\tisArrayOfType(isPointCoordinates);\nexport const isMultiPoint = isGeometryObject<MultiPoint>(\n\t'MultiPoint',\n\tisMultiPointCoordinates,\n);\nexport const isStrictMultiPointCoordinates: Guard<MultiPoint['coordinates']> =\n\tisArrayOfType(isStrictPointCoordinates);\nexport const isStrictMultiPoint = isGeometryObject<MultiPoint>(\n\t'MultiPoint',\n\tisStrictMultiPointCoordinates,\n);\n","import type { Guard } from '@konfirm/guard';\nimport {\n\tisPosition,\n\tisStrictPosition,\n\ttype Position,\n} from '../Concept/Position';\nimport { type GeometryObject, isGeometryObject } from '../GeometryObject';\n\nexport type Point = GeometryObject<{\n\ttype: 'Point';\n\tcoordinates: Position;\n}>;\nexport const isPointCoordinates: Guard<Point['coordinates']> = isPosition;\nexport const isPoint: Guard<Point> = isGeometryObject<Point>(\n\t'Point',\n\tisPointCoordinates,\n);\nexport const isStrictPointCoordinates: Guard<Point['coordinates']> =\n\tisStrictPosition;\nexport const isStrictPoint: Guard<Point> = isGeometryObject<Point>(\n\t'Point',\n\tisStrictPointCoordinates,\n);\n","import type { Guard } from '@konfirm/guard';\nimport { type GeometryObject, isGeometryObject } from '../GeometryObject';\nimport {\n\tisMultiPointCoordinates,\n\tisStrictMultiPointCoordinates,\n\ttype MultiPoint,\n} from './MultiPoint';\n\nexport type LineString = GeometryObject<{\n\ttype: 'LineString';\n\tcoordinates: MultiPoint['coordinates'];\n}>;\nexport const isLineStringCoordinates = isMultiPointCoordinates;\nexport const isLineString: Guard<LineString> = isGeometryObject<LineString>(\n\t'LineString',\n\tisLineStringCoordinates,\n);\nexport const isStrictLineStringCoordinates = isStrictMultiPointCoordinates;\nexport const isStrictLineString: Guard<LineString> =\n\tisGeometryObject<LineString>('LineString', isStrictLineStringCoordinates);\n","import { isArrayOfType } from '@konfirm/guard';\nimport { isGeometryObject, type MultiGeometryObject } from '../GeometryObject';\nimport {\n\tisLineStringCoordinates,\n\tisStrictLineStringCoordinates,\n\ttype LineString,\n} from './LineString';\n\nexport type MultiLineString = MultiGeometryObject<LineString>;\nexport const isMultiLineStringCoordinates = isArrayOfType(\n\tisLineStringCoordinates,\n);\nexport const isMultiLineString = isGeometryObject<MultiLineString>(\n\t'MultiLineString',\n\tisMultiLineStringCoordinates,\n);\nexport const isStrictMultiLineStringCoordinates = isArrayOfType(\n\tisStrictLineStringCoordinates,\n);\nexport const isStrictMultiLineString = isGeometryObject<MultiLineString>(\n\t'MultiLineString',\n\tisStrictMultiLineStringCoordinates,\n);\n","import { isArrayOfType } from '@konfirm/guard';\nimport { isGeometryObject, type MultiGeometryObject } from '../GeometryObject';\nimport {\n\tisPolygonCoordinates,\n\tisStrictPolygonCoordinates,\n\ttype Polygon,\n} from './Polygon';\n\nexport type MultiPolygon = MultiGeometryObject<Polygon>;\nexport const isMultiPolygonCoordinates = isArrayOfType(isPolygonCoordinates);\nexport const isMultiPolygon = isGeometryObject<MultiPolygon>(\n\t'MultiPolygon',\n\tisMultiPolygonCoordinates,\n);\nexport const isStrictMultiPolygonCoordinates = isArrayOfType(\n\tisStrictPolygonCoordinates,\n);\nexport const isStrictMultiPolygon = isGeometryObject<MultiPolygon>(\n\t'MultiPolygon',\n\tisStrictMultiPolygonCoordinates,\n);\n","import { all, isArrayOfType } from '@konfirm/guard';\nimport { type ExteriorRing, isExteriorRing } from '../Concept/ExteriorRing';\nimport { type InteriorRing, isInteriorRing } from '../Concept/InteriorRing';\nimport { isLinearRing, isStrictLinearRing } from '../Concept/LinearRing';\nimport { type GeometryObject, isGeometryObject } from '../GeometryObject';\n\nexport type Polygon = GeometryObject<{\n\ttype: 'Polygon';\n\tcoordinates: [ExteriorRing, ...Array<InteriorRing>];\n}>;\nexport const isPolygonCoordinates = all(isArrayOfType(isLinearRing));\nexport const isPolygon = isGeometryObject<Polygon>(\n\t'Polygon',\n\tisPolygonCoordinates,\n);\nexport const isStrictPolygonCoordinates = all(\n\tisArrayOfType(isStrictLinearRing),\n\t(value: unknown) => isExteriorRing((<Array<unknown>>value)[0]),\n\t(value: unknown) => (<Array<unknown>>value).slice(1).every(isInteriorRing),\n);\nexport const isStrictPolygon = isGeometryObject<Polygon>(\n\t'Polygon',\n\tisStrictPolygonCoordinates,\n);\n","import { all } from '@konfirm/guard';\nimport { isCounterClockwiseWinding } from '../../Utility/Winding';\nimport {\n\tisLinearRing,\n\tisStrictLinearRing,\n\ttype LinearRing,\n} from './LinearRing';\n\nexport type ExteriorRing = LinearRing;\nexport const isExteriorRing = all<ExteriorRing>(isLinearRing);\nexport const isStrictExteriorRing = all<ExteriorRing>(\n\tisStrictLinearRing,\n\tisCounterClockwiseWinding,\n);\n","import { isArrayOfType } from '@konfirm/guard';\nimport { isPosition, type Position } from '../GeoJSON/Concept/Position';\n\nfunction winding(positions: Array<Position>): number {\n\treturn positions.reduce((carry, [x, y], i, a) => {\n\t\tconst [nx, ny] = a[(i + 1) % a.length];\n\n\t\treturn carry + (nx - x) * (ny + y);\n\t}, 0);\n}\n\nconst isPositionArray = isArrayOfType<Array<Position>>(isPosition);\n\nexport function isClockwiseWinding<T extends Array<Position>>(\n\tvalue: unknown,\n): value is T {\n\treturn isPositionArray(value) && winding(value) <= 0;\n}\nexport function isCounterClockwiseWinding<T extends Array<Position>>(\n\tvalue: unknown,\n): value is T {\n\treturn isPositionArray(value) && winding(value) >= 0;\n}\n","import { all, isArrayOfSize, isArrayOfType } from '@konfirm/guard';\nimport { isPosition, isStrictPosition, type Position } from './Position';\n\nexport type LinearRing = Array<Position>;\nexport const isLinearRing = all<LinearRing>(\n\tisArrayOfType(isPosition),\n\tisArrayOfSize(4),\n\t(value: Array<Position>) =>\n\t\tvalue[value.length - 1].every((v, i) => v === value[0][i]),\n);\nexport const isStrictLinearRing = all<LinearRing>(\n\tisArrayOfType(isStrictPosition),\n\tisArrayOfSize(4),\n\t(value: Array<Position>) =>\n\t\tvalue[value.length - 1].every((v, i) => v === value[0][i]),\n);\n","import { all } from '@konfirm/guard';\nimport { isClockwiseWinding } from '../../Utility/Winding';\nimport {\n\tisLinearRing,\n\tisStrictLinearRing,\n\ttype LinearRing,\n} from './LinearRing';\n\nexport type InteriorRing = LinearRing;\nexport const isInteriorRing = all<InteriorRing>(isLinearRing);\nexport const isStrictInteriorRing = all<InteriorRing>(\n\tisStrictLinearRing,\n\tisClockwiseWinding,\n);\n","import { all, any, isArrayOfType, isKeyOfType } from '@konfirm/guard';\nimport { type GeoJSONObject, isGeoJSONObject } from './Concept/GeoJSONObject';\nimport { type Geometry, isGeometry, isStrictGeometry } from './Geometry';\n\nexport type GeometryCollection = GeoJSONObject<{\n\ttype: 'GeometryCollection';\n\tgeometries: Array<Geometry | GeometryCollection>;\n}>;\n\nconst isGeometryCollectionObject = all<GeometryCollection>(\n\tisGeoJSONObject('GeometryCollection'),\n\tisKeyOfType(\n\t\t'geometries',\n\t\tisArrayOfType(any(isGeometry, isGeometryCollection)),\n\t),\n);\nconst isStrictGeometryCollectionObject = all<GeometryCollection>(\n\tisGeoJSONObject('GeometryCollection'),\n\tisKeyOfType(\n\t\t'geometries',\n\t\tisArrayOfType(any(isStrictGeometry, isStrictGeometryCollection)),\n\t),\n);\nexport function isGeometryCollection(\n\tvalue: unknown,\n): value is GeometryCollection {\n\treturn isGeometryCollectionObject(value);\n}\nexport function isStrictGeometryCollection(\n\tvalue: unknown,\n): value is GeometryCollection {\n\treturn isStrictGeometryCollectionObject(value);\n}\n","import { all, isArrayOfType, isKeyOfType } from '@konfirm/guard';\nimport { type GeoJSONObject, isGeoJSONObject } from './Concept/GeoJSONObject';\nimport { type Feature, isFeature, isStrictFeature } from './Feature';\n\nexport type FeatureCollection = GeoJSONObject<{\n\ttype: 'FeatureCollection';\n\tfeatures: Array<Feature>;\n}>;\nexport const isFeatureCollection = all<FeatureCollection>(\n\tisGeoJSONObject('FeatureCollection'),\n\tisKeyOfType('features', isArrayOfType(isFeature)),\n);\nexport const isStrictFeatureCollection = all<FeatureCollection>(\n\tisGeoJSONObject('FeatureCollection'),\n\tisKeyOfType('features', isArrayOfType(isStrictFeature)),\n);\n","import { any } from '@konfirm/guard';\nimport { type Feature, isFeature, isStrictFeature } from './Feature';\nimport {\n\ttype FeatureCollection,\n\tisFeatureCollection,\n\tisStrictFeatureCollection,\n} from './FeatureCollection';\nimport { type Geometry, isGeometry, isStrictGeometry } from './Geometry';\nimport {\n\ttype GeometryCollection,\n\tisGeometryCollection,\n\tisStrictGeometryCollection,\n} from './GeometryCollection';\n\nexport type GeoJSON =\n\t| Geometry\n\t| GeometryCollection\n\t| Feature\n\t| FeatureCollection;\nexport const isGeoJSON = any<GeoJSON>(\n\tisGeometry,\n\tisGeometryCollection,\n\tisFeature,\n\tisFeatureCollection,\n);\nexport const isStrictGeoJSON = any<GeoJSON>(\n\tisStrictGeometry,\n\tisStrictGeometryCollection,\n\tisStrictFeature,\n\tisStrictFeatureCollection,\n);\n","import type {\n\tLineString,\n\tMultiLineString,\n\tMultiPoint,\n\tMultiPolygon,\n\tPoint,\n\tPolygon,\n} from '../../main';\nimport type { Feature } from '../GeoJSON/Feature';\nimport type { FeatureCollection } from '../GeoJSON/FeatureCollection';\nimport type { GeoJSON } from '../GeoJSON/GeoJSON';\nimport type { GeometryCollection } from '../GeoJSON/GeometryCollection';\n\ntype SimpleGeometry = Point | LineString | Polygon;\ntype UnwrapGeometry = Exclude<GeoJSON, SimpleGeometry>;\n\ntype Reducer = {\n\t[K in UnwrapGeometry['type']]: (\n\t\tgeo: Extract<UnwrapGeometry, { type: K }>,\n\t\tunwrap: (geo: GeoJSON) => Iterable<SimpleGeometry>,\n\t) => Iterable<SimpleGeometry>;\n};\n\nconst reducers: Reducer = {\n\t*MultiPoint(\n\t\t{ coordinates, ...rest }: MultiPoint,\n\t\tunwrap,\n\t): Iterable<SimpleGeometry> {\n\t\tfor (const pair of coordinates) {\n\t\t\tyield* unwrap(<Point>{\n\t\t\t\tcoordinates: pair,\n\t\t\t\t...rest,\n\t\t\t\ttype: 'Point',\n\t\t\t});\n\t\t}\n\t},\n\t*MultiLineString(\n\t\t{ coordinates, ...rest }: MultiLineString,\n\t\tunwrap,\n\t): Iterable<SimpleGeometry> {\n\t\tfor (const pair of coordinates) {\n\t\t\tyield* unwrap(<LineString>{\n\t\t\t\tcoordinates: pair,\n\t\t\t\t...rest,\n\t\t\t\ttype: 'LineString',\n\t\t\t});\n\t\t}\n\t},\n\t*MultiPolygon(\n\t\t{ coordinates, ...rest }: MultiPolygon,\n\t\tunwrap,\n\t): Iterable<SimpleGeometry> {\n\t\tfor (const pair of coordinates) {\n\t\t\tyield* unwrap(<Polygon>{\n\t\t\t\tcoordinates: pair,\n\t\t\t\t...rest,\n\t\t\t\ttype: 'Polygon',\n\t\t\t});\n\t\t}\n\t},\n\t*GeometryCollection(\n\t\t{ geometries }: GeometryCollection,\n\t\tunwrap,\n\t): Iterable<SimpleGeometry> {\n\t\tfor (const geometry of geometries) {\n\t\t\tyield* unwrap(geometry);\n\t\t}\n\t},\n\t*Feature({ geometry }: Feature, unwrap): Iterable<SimpleGeometry> {\n\t\tyield* unwrap(geometry);\n\t},\n\t*FeatureCollection(\n\t\t{ features }: FeatureCollection,\n\t\tunwrap,\n\t): Iterable<SimpleGeometry> {\n\t\tfor (const { geometry } of features) {\n\t\t\tyield* unwrap(geometry);\n\t\t}\n\t},\n};\n\n/**\n * Iterator class to turn any GeoJSON structure into one or more SimpleGeometry (Point | LineString | Polygon) objects\n *\n * @export\n * @class SimpleGeometryIterator\n */\nexport class SimpleGeometryIterator {\n\tprivate readonly inputs: Array<GeoJSON> = [];\n\n\tconstructor(...inputs: [GeoJSON, ...Array<GeoJSON>]) {\n\t\tthis.inputs = inputs;\n\t}\n\n\t/**\n\t * Generator yielding all SimpleGeometry objects from the provided GeoJSON structure(s)\n\t *\n\t * @return {*} {Iterator<SimpleGeometry>}\n\t * @memberof SimpleGeometryIterator\n\t */\n\t*[Symbol.iterator](): Iterator<SimpleGeometry> {\n\t\tfor (const input of this.inputs) {\n\t\t\tfor (const simple of this.unwrap(input)) {\n\t\t\t\tyield simple;\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * unwrap any GeoJSON object into one or more SimpleGeometry object\n\t *\n\t * @private\n\t * @param {GeoJSON} geo\n\t * @return {*} {Iterable<SimpleGeometry>}\n\t * @memberof SimpleGeometryIterator\n\t */\n\tprivate *unwrap(geo: GeoJSON): Iterable<SimpleGeometry> {\n\t\ttype Invoke = (\n\t\t\tgeo: GeoJSON,\n\t\t\tunwrap: (geo: GeoJSON) => Iterable<SimpleGeometry>,\n\t\t) => Iterable<SimpleGeometry>;\n\t\tgeo.type in reducers\n\t\t\t? yield* (<Invoke>reducers[<keyof Reducer>geo.type])(\n\t\t\t\t\tgeo,\n\t\t\t\t\t(g: GeoJSON): Iterable<SimpleGeometry> => this.unwrap(g),\n\t\t\t\t)\n\t\t\t: yield <SimpleGeometry>geo;\n\t}\n}\n","/**\n * Iterator class which traverses all value pairs of two or more Iterable instances\n *\n * @export\n * @class IterablePairIterator\n * @template T\n */\nexport class IterablePairIterator<T = unknown> {\n\tprivate readonly iterators: Array<Iterable<T>> = [];\n\n\t/**\n\t * Constructs a new instance of IterablePairIterator\n\t *\n\t * @param iterators\n\t */\n\tconstructor(\n\t\t...iterators: [Iterable<T>, Iterable<T>, ...Array<Iterable<T>>]\n\t) {\n\t\tthis.iterators = iterators;\n\t}\n\n\t/**\n\t * Generator yielding all value pairs from the provided iterators\n\t *\n\t * @return {*} {Iterator<[T, T]>}\n\t * @memberof IterablePairIterator\n\t */\n\t*[Symbol.iterator](): Iterator<[T, T]> {\n\t\tfor (const [a, b] of this.pairs(this.iterators)) {\n\t\t\tfor (const one of a) {\n\t\t\t\tfor (const two of b) {\n\t\t\t\t\tyield [one, two];\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Create unique Iterator<T> combinations to traverse over\n\t *\n\t * @private\n\t * @param {Array<Iterable<T>>} source\n\t * @return {*} {Array<[Iterable<T>, Iterable<T>]>}\n\t * @memberof IterablePairIterator\n\t */\n\tprivate pairs(\n\t\tsource: Array<Iterable<T>>,\n\t): Array<[Iterable<T>, Iterable<T>]> {\n\t\treturn source.flatMap((a, i) =>\n\t\t\tsource.slice(i + 1).map((b) => [a, b]),\n\t\t) as Array<[Iterable<T>, Iterable<T>]>;\n\t}\n}\n","import type { GeoJSON } from '../GeoJSON/GeoJSON';\nimport type { Point } from '../GeoJSON/Geometry/Point';\nimport { SimpleGeometryIterator } from '../Iterator/SimpleGeometry';\n\nexport type Box = [\n\tminLon: number,\n\tminLat: number,\n\tmaxLon: number,\n\tmaxLat: number,\n];\n\nfunction* positions(\n\tcoordinates: Array<unknown>,\n): Generator<Point['coordinates']> {\n\tif (typeof coordinates[0] === 'number') {\n\t\tyield coordinates as Point['coordinates'];\n\t} else {\n\t\tfor (const child of coordinates as Array<Array<unknown>>) {\n\t\t\tyield* positions(child);\n\t\t}\n\t}\n}\n\nfunction boxFromPositions(source: Iterable<Point['coordinates']>): Box {\n\tlet minLon = Infinity,\n\t\tminLat = Infinity,\n\t\tmaxLon = -Infinity,\n\t\tmaxLat = -Infinity;\n\n\tfor (const [lon, lat] of source) {\n\t\tif (lon < minLon) minLon = lon;\n\t\tif (lat < minLat) minLat = lat;\n\t\tif (lon > maxLon) maxLon = lon;\n\t\tif (lat > maxLat) maxLat = lat;\n\t}\n\n\treturn [minLon, minLat, maxLon, maxLat];\n}\n\nexport function createBoxFromCoordinates(coordinates: Array<unknown>): Box {\n\treturn boxFromPositions(positions(coordinates));\n}\n\nexport function createBox(shape: GeoJSON): Box {\n\treturn boxFromPositions(\n\t\t(function* () {\n\t\t\tfor (const geometry of new SimpleGeometryIterator(shape)) {\n\t\t\t\tyield* positions(\n\t\t\t\t\t(geometry as unknown as { coordinates: Array<unknown> })\n\t\t\t\t\t\t.coordinates,\n\t\t\t\t);\n\t\t\t}\n\t\t})(),\n\t);\n}\n\nexport function isWithinBox(\n\t[lon, lat]: Point['coordinates'],\n\t[minLon, minLat, maxLon, maxLat]: Box,\n): boolean {\n\treturn lon >= minLon && lon <= maxLon && lat >= minLat && lat <= maxLat;\n}\n","import {\n\tEARTH_FLATTENING,\n\tEARTH_RADIUS,\n\tEARTH_RADIUS_MAJOR,\n\tEARTH_RADIUS_MINOR,\n} from '../Constants';\nimport type { Point } from '../GeoJSON/Geometry/Point';\nimport { createBoxFromCoordinates, isWithinBox } from './Box';\n\nconst D2R = Math.PI / 180;\nconst π = Math.PI;\n\nfunction constrain(value: number, min: number, max: number): number {\n\treturn Math.max(Math.min(value, max), min);\n}\n\nfunction squared(n: number): number {\n\treturn n * n;\n}\n\nfunction rad(n: number): number {\n\treturn n * D2R;\n}\n\nconst EARTH_RADIUS_MAJOR_SQUARED = squared(EARTH_RADIUS_MAJOR);\nconst EARTH_RADIUS_MINOR_SQUARED = squared(EARTH_RADIUS_MINOR);\nconst EARTH_RADIUS_FACTOR =\n\t(EARTH_RADIUS_MAJOR_SQUARED - EARTH_RADIUS_MINOR_SQUARED) /\n\tEARTH_RADIUS_MINOR_SQUARED;\nconst EARTH_INVERSE_FLATTENING = 1 / EARTH_FLATTENING;\n\nconst PointToPoint: {\n\t[key: string]: (\n\t\t...positions: [Point['coordinates'], Point['coordinates']]\n\t) => number;\n} = {\n\tcartesian([λa, φa], [λb, φb]) {\n\t\treturn (\n\t\t\tEARTH_RADIUS * rad(Math.sqrt(squared(λb - λa) + squared(φb - φa)))\n\t\t);\n\t},\n\thaversine([λa, φa], [λb, φb]) {\n\t\t//https://www.movable-type.co.uk/scripts/latlong.html\n\t\tconst Δ =\n\t\t\tsquared(Math.sin(rad(φb - φa) / 2)) +\n\t\t\tMath.cos(rad(φa)) *\n\t\t\t\tMath.cos(rad(φb)) *\n\t\t\t\tsquared(Math.sin(rad(λb - λa) / 2));\n\n\t\treturn EARTH_RADIUS * Math.atan2(Math.sqrt(Δ), Math.sqrt(1 - Δ)) * 2;\n\t},\n\tvincenty(...points) {\n\t\t//https://www.movable-type.co.uk/scripts/latlong-vincenty.html\n\t\tconst [[λ1, φ1], [λ2, φ2]] = points.map((p) =>\n\t\t\t(<Array<number>>p).map(rad),\n\t\t);\n\t\tconst L = λ2 - λ1; // L = difference in longitude, U = reduced latitude, defined by tan U = (1-f)·tanφ.\n\t\tconst tanU1 = (1 - EARTH_INVERSE_FLATTENING) * Math.tan(φ1),\n\t\t\tcosU1 = 1 / Math.sqrt(1 + tanU1 * tanU1),\n\t\t\tsinU1 = tanU1 * cosU1;\n\t\tconst tanU2 = (1 - EARTH_INVERSE_FLATTENING) * Math.tan(φ2),\n\t\t\tcosU2 = 1 / Math.sqrt(1 + tanU2 * tanU2),\n\t\t\tsinU2 = tanU2 * cosU2;\n\n\t\tconst antipodal = Math.abs(L) > π / 2 || Math.abs(φ2 - φ1) > π / 2;\n\n\t\tlet λ = L;\n\t\tlet sinλ = null;\n\t\tlet cosλ = null; // λ = difference in longitude on an auxiliary sphere\n\t\tlet σ = antipodal ? π : 0;\n\t\tlet sinσ = 0;\n\t\tlet cosσ = antipodal ? -1 : 1;\n\t\tlet sinSqσ = null; // σ = angular distance P₁ P₂ on the sphere\n\t\tlet cos2σₘ = 1; // σₘ = angular distance on the sphere from the equator to the midpoint of the line\n\t\tlet cosSqα = 1; // α = azimuth of the geodesic at the equator\n\t\tlet λʹ = null;\n\t\tlet iterations = 0;\n\n\t\tdo {\n\t\t\tsinλ = Math.sin(λ);\n\t\t\tcosλ = Math.cos(λ);\n\t\t\tsinSqσ =\n\t\t\t\t(cosU2 * sinλ) ** 2 +\n\t\t\t\t(cosU1 * sinU2 - sinU1 * cosU2 * cosλ) ** 2;\n\t\t\tif (Math.abs(sinSqσ) < 1e-24) break; // co-incident/antipodal points (σ < ≈0.006mm)\n\t\t\tsinσ = Math.sqrt(sinSqσ);\n\t\t\tcosσ = sinU1 * sinU2 + cosU1 * cosU2 * cosλ;\n\t\t\tσ = Math.atan2(sinσ, cosσ);\n\t\t\tconst sinα = (cosU1 * cosU2 * sinλ) / sinσ;\n\t\t\tcosSqα = 1 - sinα * sinα;\n\t\t\tcos2σₘ = cosSqα !== 0 ? cosσ - (2 * sinU1 * sinU2) / cosSqα : 0; // on equatorial line cos²α = 0 (§6)\n\t\t\tconst C =\n\t\t\t\t(EARTH_INVERSE_FLATTENING / 16) *\n\t\t\t\tcosSqα *\n\t\t\t\t(4 + EARTH_INVERSE_FLATTENING * (4 - 3 * cosSqα));\n\t\t\tλʹ = λ;\n\t\t\tλ =\n\t\t\t\tL +\n\t\t\t\t(1 - C) *\n\t\t\t\t\tEARTH_INVERSE_FLATTENING *\n\t\t\t\t\tsinα *\n\t\t\t\t\t(σ +\n\t\t\t\t\t\tC *\n\t\t\t\t\t\t\tsinσ *\n\t\t\t\t\t\t\t(cos2σₘ + C * cosσ * (-1 + 2 * cos2σₘ * cos2σₘ)));\n\t\t\t// TODO: add tests\n\t\t\t// const iterationCheck = antipodal ? Math.abs(λ) - π : Math.abs(λ);\n\t\t\t// if (iterationCheck > π) throw new EvalError('λ > π');\n\t\t} while (Math.abs(λ - λʹ) > 1e-12 && ++iterations < 1000); // TV: 'iterate until negligible change in λ' (≈0.006mm)\n\t\t// TODO: add tests\n\t\t// if (iterations >= 1000) throw new EvalError('Vincenty formula failed to converge');\n\n\t\tconst uSq = cosSqα * EARTH_RADIUS_FACTOR;\n\t\tconst A =\n\t\t\t1 + (uSq / 16384) * (4096 + uSq * (-768 + uSq * (320 - 175 * uSq)));\n\t\tconst B = (uSq / 1024) * (256 + uSq * (-128 + uSq * (74 - 47 * uSq)));\n\t\tconst Δσ =\n\t\t\tB *\n\t\t\tsinσ *\n\t\t\t(cos2σₘ +\n\t\t\t\t(B / 4) *\n\t\t\t\t\t(cosσ * (-1 + 2 * cos2σₘ * cos2σₘ) -\n\t\t\t\t\t\t(B / 6) *\n\t\t\t\t\t\t\tcos2σₘ *\n\t\t\t\t\t\t\t(-3 + 4 * sinσ * sinσ) *\n\t\t\t\t\t\t\t(-3 + 4 * cos2σₘ * cos2σₘ)));\n\n\t\treturn EARTH_RADIUS_MINOR * A * (σ - Δσ);\n\t},\n};\n\nexport type PointToPointCalculation =\n\t| 'cartesian'\n\t| 'haversine'\n\t| 'vincenty'\n\t| ((a: Point['coordinates'], b: Point['coordinates']) => number);\n\nexport function getClosestPointOnLineByPoint(\n\tpoint: Point['coordinates'],\n\tline: [Point['coordinates'], Point['coordinates']],\n): Point['coordinates'] {\n\tconst [[px, py], [ax, ay], [bx, by]] = [point, ...line];\n\tconst [abx, aby] = [bx - ax, by - ay];\n\tconst [apx, apy] = [px - ax, py - ay];\n\tconst t = constrain(\n\t\t(apx * abx + apy * aby) / (abx * abx + aby * aby),\n\t\t0,\n\t\t1,\n\t);\n\n\treturn t === 0 || t === 1 ? line[t] : [ax + abx * t, ay + aby * t];\n}\n\nexport function getDistanceOfPointToPoint(\n\ta: Point['coordinates'],\n\tb: Point['coordinates'],\n\tcalculation: PointToPointCalculation,\n): number {\n\tconst calc =\n\t\ttypeof calculation === 'function'\n\t\t\t? calculation\n\t\t\t: PointToPoint[calculation];\n\n\tif (typeof calc === 'function') {\n\t\treturn calc(a, b);\n\t}\n\n\tthrow new Error(`Not a PointToPoint calculation function ${calculation}`);\n}\n\nexport function getDistanceOfPointToLine(\n\tpoint: Point['coordinates'],\n\tline: [Point['coordinates'], Point['coordinates']],\n\tcalculation: PointToPointCalculation,\n): number {\n\treturn getDistanceOfPointToPoint(\n\t\tpoint,\n\t\tgetClosestPointOnLineByPoint(point, line),\n\t\tcalculation,\n\t);\n}\n\nexport function getDistanceOfLineToLine(\n\ta: [Point['coordinates'], Point['coordinates']],\n\tb: [Point['coordinates'], Point['coordinates']],\n\tcalculation: PointToPointCalculation,\n): number {\n\treturn isLinesCrossing(a, b)\n\t\t? 0\n\t\t: Math.min(\n\t\t\t\t...a.map((a) => getDistanceOfPointToLine(a, b, calculation)),\n\t\t\t\t...b.map((b) => getDistanceOfPointToLine(b, a, calculation)),\n\t\t\t);\n}\n\nexport function isLinesCrossing(\n\ta: [Point['coordinates'], Point['coordinates']],\n\tb: [Point['coordinates'], Point['coordinates']],\n): boolean {\n\tconst [[a1x, a1y], [a2x, a2y]] = a;\n\tconst [[b1x, b1y], [b2x, b2y]] = b;\n\tconst [s1x, s1y, s2x, s2y] = [a2x - a1x, a2y - a1y, b2x - b1x, b2y - b1y];\n\tconst s =\n\t\t(-s1y * (a1x - b1x) + s1x * (a1y - b1y)) / (-s2x * s1y + s1x * s2y);\n\tconst t =\n\t\t(s2x * (a1y - b1y) - s2y * (a1x - b1x)) / (-s2x * s1y + s1x * s2y);\n\n\treturn s >= 0 && s <= 1 && t >= 0 && t <= 1;\n}\n\nexport function isPointOnLine(\n\tpoint: Point['coordinates'],\n\tline: [Point['coordinates'], Point['coordinates']],\n\tthreshold: number = 1e-14,\n): boolean {\n\treturn getDistanceOfPointToLine(point, line, 'cartesian') < threshold;\n}\n\nexport function isPointInRing(\n\tp: Point['coordinates'],\n\tring: Array<Point['coordinates']>,\n): boolean {\n\tif (!isWithinBox(p, createBoxFromCoordinates(ring))) {\n\t\treturn false;\n\t}\n\n\tconst { length } = ring;\n\tconst odd = ring.reduce((odd, a, i) => {\n\t\tconst b = ring[(length + i - 1) % length];\n\n\t\treturn ((a[1] < p[1] && b[1] >= p[1]) ||\n\t\t\t(b[1] < p[1] && a[1] >= p[1])) &&\n\t\t\t(a[0] <= p[0] || b[0] <= p[0])\n\t\t\t? odd ^\n\t\t\t\t\tNumber(\n\t\t\t\t\t\ta[0] + ((p[1] - a[1]) / (b[1] - a[1])) * (b[0] - a[0]) <\n\t\t\t\t\t\t\tp[0],\n\t\t\t\t\t)\n\t\t\t: odd;\n\t}, 0);\n\n\treturn (\n\t\todd !== 0 ||\n\t\tring.slice(1).some((a, index) => isPointOnLine(p, [ring[index], a]))\n\t);\n}\n","import type { Point } from '../GeoJSON/Geometry/Point';\n\nexport function segments(\n\tline: Array<Point['coordinates']>,\n): Array<[Point['coordinates'], Point['coordinates']]> {\n\treturn line.slice(1).map((point, index) => [line[index], point]);\n}\n","import type { GeoJSON } from '../GeoJSON/GeoJSON';\nimport type { LineString } from '../GeoJSON/Geometry/LineString';\nimport type { Point } from '../GeoJSON/Geometry/Point';\nimport type { Polygon } from '../GeoJSON/Geometry/Polygon';\nimport { IterablePairIterator } from '../Iterator/IterablePair';\nimport { SimpleGeometryIterator } from '../Iterator/SimpleGeometry';\nimport {\n\tgetDistanceOfLineToLine,\n\tgetDistanceOfPointToLine,\n\tgetDistanceOfPointToPoint,\n\tisPointInRing,\n\ttype PointToPointCalculation,\n} from './Calculate';\nimport { segments } from './Segments';\n\nconst geometries = {\n\tPointPoint(\n\t\ta: Point['coordinates'],\n\t\tb: Point['coordinates'],\n\t\tcalculation: PointToPointCalculation,\n\t): number {\n\t\treturn getDistanceOfPointToPoint(a, b, calculation);\n\t},\n\tLineStringPoint(\n\t\ta: LineString['coordinates'],\n\t\tb: Point['coordinates'],\n\t\tcalculation: PointToPointCalculation,\n\t): number {\n\t\treturn Math.min(\n\t\t\t...segments(a).map((line) =>\n\t\t\t\tgetDistanceOfPointToLine(b, line, calculation),\n\t\t\t),\n\t\t);\n\t},\n\tLineStringLineString(\n\t\ta: LineString['coordinates'],\n\t\tb: LineString['coordinates'],\n\t\tcalculation: PointToPointCalculation,\n\t): number {\n\t\tconst sa = segments(a);\n\t\tconst sb = segments(b);\n\n\t\treturn sa.reduce(\n\t\t\t(carry, a) =>\n\t\t\t\tsb.reduce(\n\t\t\t\t\t(carry, b) =>\n\t\t\t\t\t\tcarry > 0\n\t\t\t\t\t\t\t? Math.min(\n\t\t\t\t\t\t\t\t\tcarry,\n\t\t\t\t\t\t\t\t\tgetDistanceOfLineToLine(a, b, calculation),\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t: carry,\n\t\t\t\t\tcarry,\n\t\t\t\t),\n\t\t\tInfinity,\n\t\t);\n\t},\n\tPolygonPoint(\n\t\t[exterior, ...interior]: Polygon['coordinates'],\n\t\tb: Point['coordinates'],\n\t\tcalculation: PointToPointCalculation,\n\t): number {\n\t\tif (isPointInRing(b, exterior)) {\n\t\t\tconst [excluded] = interior.filter((ring) =>\n\t\t\t\tisPointInRing(b, ring),\n\t\t\t);\n\n\t\t\treturn excluded\n\t\t\t\t? this.LineStringPoint(excluded, b, calculation)\n\t\t\t\t: 0;\n\t\t}\n\n\t\treturn this.LineStringPoint(exterior, b, calculation);\n\t},\n\tPolygonLineString(\n\t\ta: Polygon['coordinates'],\n\t\tb: LineString['coordinates'],\n\t\tcalculation: PointToPointCalculation,\n\t): number {\n\t\tconst [exterior, ...interior] = a;\n\t\tconst line = segments(b);\n\t\tconst ring = b.some((b) => isPointInRing(b, exterior))\n\t\t\t? interior.find((a) => b.every((b) => isPointInRing(b, a)))\n\t\t\t: exterior;\n\n\t\treturn ring\n\t\t\t? Math.min(\n\t\t\t\t\t...segments(ring).map((a) =>\n\t\t\t\t\t\tMath.min(\n\t\t\t\t\t\t\t...line.map((b) =>\n\t\t\t\t\t\t\t\tgetDistanceOfLineToLine(a, b, calculation),\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t),\n\t\t\t\t\t),\n\t\t\t\t)\n\t\t\t: 0;\n\t},\n\tPolygonPolygon(\n\t\ta: Polygon['coordinates'],\n\t\tb: Polygon['coordinates'],\n\t\tcalculation: PointToPointCalculation,\n\t): number {\n\t\treturn Math.min(\n\t\t\tthis.PolygonLineString(a, b[0], calculation),\n\t\t\tthis.PolygonLineString(b, a[0], calculation),\n\t\t);\n\t},\n};\n\nexport function distance(\n\ta: GeoJSON,\n\tb: GeoJSON,\n\tcalculation: PointToPointCalculation = 'cartesian',\n): number {\n\tconst lookup = <\n\t\tRecord<\n\t\t\tstring,\n\t\t\t(\n\t\t\t\ta: unknown,\n\t\t\t\tb: unknown,\n\t\t\t\tcalculation: PointToPointCalculation,\n\t\t\t) => number\n\t\t>\n\t>geometries;\n\treturn Math.min(\n\t\t...[\n\t\t\t...new IterablePairIterator(\n\t\t\t\tnew SimpleGeometryIterator(a),\n\t\t\t\tnew SimpleGeometryIterator(b),\n\t\t\t),\n\t\t].map(([a, b]) => {\n\t\t\treturn a.type + b.type in lookup\n\t\t\t\t? lookup[a.type + b.type](\n\t\t\t\t\t\ta.coordinates,\n\t\t\t\t\t\tb.coordinates,\n\t\t\t\t\t\tcalculation,\n\t\t\t\t\t)\n\t\t\t\t: b.type + a.type in lookup\n\t\t\t\t\t? lookup[b.type + a.type](\n\t\t\t\t\t\t\tb.coordinates,\n\t\t\t\t\t\t\ta.coordinates,\n\t\t\t\t\t\t\tcalculation,\n\t\t\t\t\t\t)\n\t\t\t\t\t: Infinity;\n\t\t}),\n\t);\n}\n","import type { GeoJSON } from '../GeoJSON/GeoJSON';\nimport type { LineString } from '../GeoJSON/Geometry/LineString';\nimport type { Point } from '../GeoJSON/Geometry/Point';\nimport type { Polygon } from '../GeoJSON/Geometry/Polygon';\nimport { IterablePairIterator } from '../Iterator/IterablePair';\nimport { SimpleGeometryIterator } from '../Iterator/SimpleGeometry';\nimport { isLinesCrossing, isPointInRing, isPointOnLine } from './Calculate';\nimport { segments } from './Segments';\n\nconst geometries = {\n\tPointPoint(a: Point['coordinates'], b: Point['coordinates']): boolean {\n\t\treturn (\n\t\t\ta.length >= 2 &&\n\t\t\tb.length >= 2 &&\n\t\t\ta.slice(0, 2).every((v, i) => v === b[i])\n\t\t);\n\t},\n\tLineStringPoint(\n\t\ta: LineString['coordinates'],\n\t\tb: Point['coordinates'],\n\t): boolean {\n\t\treturn (\n\t\t\ta.some((a) => this.PointPoint(a, b)) ||\n\t\t\tsegments(a).some((line) => isPointOnLine(b, line))\n\t\t);\n\t},\n\tLineStringLineString(\n\t\ta: LineString['coordinates'],\n\t\tb: LineString['coordinates'],\n\t): boolean {\n\t\tconst lines = segments(b);\n\n\t\treturn segments(a).some((a) =>\n\t\t\tlines.some((b) => isLinesCrossing(a, b)),\n\t\t);\n\t},\n\tPolygonPoint(\n\t\t[exterior, ...interior]: Polygon['coordinates'],\n\t\tb: Point['coordinates'],\n\t): boolean {\n\t\treturn (\n\t\t\t(this.LineStringPoint(exterior, b) || isPointInRing(b, exterior)) &&\n\t\t\t(!interior.length ||\n\t\t\t\tinterior.every((ring) => !isPointInRing(b, ring)))\n\t\t);\n\t},\n\tPolygonLineString(\n\t\ta: Polygon['coordinates'],\n\t\tb: LineString['coordinates'],\n\t): boolean {\n\t\treturn (\n\t\t\ta.some((ring) => this.LineStringLineString(ring, b)) ||\n\t\t\tb.some((point) => this.PolygonPoint(a, point))\n\t\t);\n\t},\n\tPolygonPolygon(\n\t\ta: Polygon['coordinates'],\n\t\tb: Polygon['coordinates'],\n\t): boolean {\n\t\treturn (\n\t\t\tb.some(\n\t\t\t\t(b1) =>\n\t\t\t\t\tthis.PolygonLineString(a, b1) ||\n\t\t\t\t\tb1.some((b2) => this.PolygonPoint(a, b2)),\n\t\t\t) ||\n\t\t\ta.some(\n\t\t\t\t(a1) =>\n\t\t\t\t\tthis.PolygonLineString(b, a1) ||\n\t\t\t\t\ta1.some((a2) => this.PolygonPoint(b, a2)),\n\t\t\t)\n\t\t);\n\t},\n};\n\nexport function intersect(a: GeoJSON, b: GeoJSON): boolean {\n\tconst lookup = <Record<string, (a: unknown, b: unknown) => boolean>>(\n\t\tgeometries\n\t);\n\tfor (const [itA, itB] of new IterablePairIterator(\n\t\tnew SimpleGeometryIterator(a),\n\t\tnew SimpleGeometryIterator(b),\n\t)) {\n\t\tif (\n\t\t\t(itA.type + itB.type in lookup &&\n\t\t\t\tlookup[itA.type + itB.type](\n\t\t\t\t\titA.coordinates,\n\t\t\t\t\titB.coordinates,\n\t\t\t\t)) ||\n\t\t\t(itB.type + itA.type in lookup &&\n\t\t\t\tlookup[itB.type + itA.type](itB.coordinates, itA.coordinates))\n\t\t) {\n\t\t\treturn true;\n\t\t}\n\t}\n\n\treturn false;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AA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AAC,OACA,KAAK,kBAAkB,GAAG,EAAE,KAC5B,GAAG,KAAK,CAAC,OAAO,KAAK,aAAa,GAAG,EAAE,CAAC;AAAA,IAC1C;AAAA,EAEF;AACD;AAEO,SAAS,UAAU,GAAY,GAAqB;AAC1D,QAAM,SACLF;AAED,aAAW,CAAC,KAAK,GAAG,KAAK,IAAI;AAAA,IAC5B,IAAI,uBAAuB,CAAC;AAAA,IAC5B,IAAI,uBAAuB,CAAC;AAAA,EAC7B,GAAG;AACF,QACE,IAAI,OAAO,IAAI,QAAQ,UACvB,OAAO,IAAI,OAAO,IAAI,IAAI;AAAA,MACzB,IAAI;AAAA,MACJ,IAAI;AAAA,IACL,KACA,IAAI,OAAO,IAAI,QAAQ,UACvB,OAAO,IAAI,OAAO,IAAI,IAAI,EAAE,IAAI,aAAa,IAAI,WAAW,GAC5D;AACD,aAAO;AAAA,IACR;AAAA,EACD;AAEA,SAAO;AACR;","names":["import_guard","import_guard","import_guard","import_guard","import_guard","import_guard","import_guard","import_guard","import_guard","import_guard","import_guard","import_guard","import_guard","positions","import_guard","import_guard","import_guard","import_guard","import_guard","geometries","a","b","odd","a","carry","b","geometries","a","b"]}
|
|
1
|
+
{"version":3,"sources":["../source/main.ts","../node_modules/@konfirm/guard/dist/guard.es.js","../source/Domain/Guards/Tuple.ts","../source/Domain/Constants.ts","../source/Domain/Guards/Number.ts","../source/Domain/GeoJSON/Concept/Altitude.ts","../source/Domain/GeoJSON/Concept/Latitude.ts","../source/Domain/GeoJSON/Concept/Longitude.ts","../source/Domain/GeoJSON/Concept/Position.ts","../source/Domain/GeoJSON/Concept/BoundingBox.ts","../source/Domain/GeoJSON/Concept/GeoJSONObject.ts","../source/Domain/GeoJSON/GeometryObject.ts","../source/Domain/GeoJSON/Geometry/Point.ts","../source/Domain/GeoJSON/Geometry/MultiPoint.ts","../source/Domain/GeoJSON/Geometry/LineString.ts","../source/Domain/GeoJSON/Geometry/MultiLineString.ts","../source/Domain/Utility/Winding.ts","../source/Domain/GeoJSON/Concept/LinearRing.ts","../source/Domain/GeoJSON/Concept/ExteriorRing.ts","../source/Domain/GeoJSON/Concept/InteriorRing.ts","../source/Domain/GeoJSON/Geometry/Polygon.ts","../source/Domain/GeoJSON/Geometry/MultiPolygon.ts","../source/Domain/GeoJSON/Geometry.ts","../source/Domain/GeoJSON/Feature.ts","../source/Domain/GeoJSON/FeatureCollection.ts","../source/Domain/GeoJSON/GeoJSON.ts","../source/Domain/Iterator/SimpleGeometry.ts","../source/Domain/Iterator/IterablePair.ts","../source/Domain/Utility/Box.ts","../source/Domain/Utility/Common.ts","../source/Domain/Utility/Numeric.ts","../source/Domain/Utility/Geodesic.ts","../source/Domain/Utility/Calculate.ts","../source/Domain/Utility/Segments.ts","../source/Domain/Utility/Distance.ts","../source/Domain/Utility/Intersect.ts"],"sourcesContent":["// intersect and distance functions\n\n// the individual GeoJSON types and type guards\nexport {\n\tisPosition,\n\tisStrictPosition,\n\tPosition,\n} from './Domain/GeoJSON/Concept/Position';\nexport { Feature, isFeature, isStrictFeature } from './Domain/GeoJSON/Feature';\nexport {\n\tFeatureCollection,\n\tisFeatureCollection,\n\tisStrictFeatureCollection,\n} from './Domain/GeoJSON/FeatureCollection';\nexport { GeoJSON, isGeoJSON, isStrictGeoJSON } from './Domain/GeoJSON/GeoJSON';\nexport {\n\tGeometry,\n\tGeometryCollection,\n\tGeometryPrimitive,\n\tisGeometry,\n\tisGeometryCollection,\n\tisGeometryPrimitive,\n\tisStrictGeometry,\n\tisStrictGeometryCollection,\n\tisStrictGeometryPrimitive,\n} from './Domain/GeoJSON/Geometry';\nexport {\n\tisLineString,\n\tisStrictLineString,\n\tLineString,\n} from './Domain/GeoJSON/Geometry/LineString';\nexport {\n\tisMultiLineString,\n\tisStrictMultiLineString,\n\tMultiLineString,\n} from './Domain/GeoJSON/Geometry/MultiLineString';\nexport {\n\tisMultiPoint,\n\tisStrictMultiPoint,\n\tMultiPoint,\n} from './Domain/GeoJSON/Geometry/MultiPoint';\nexport {\n\tisMultiPolygon,\n\tisStrictMultiPolygon,\n\tMultiPolygon,\n} from './Domain/GeoJSON/Geometry/MultiPolygon';\nexport { isPoint, isStrictPoint, Point } from './Domain/GeoJSON/Geometry/Point';\nexport {\n\tisPolygon,\n\tisStrictPolygon,\n\tPolygon,\n} from './Domain/GeoJSON/Geometry/Polygon';\nexport { SimpleGeometryIterator } from './Domain/Iterator/SimpleGeometry';\nexport {\n\tcartesian,\n\tdistance,\n\thaversine,\n\tkarney,\n\tvincenty,\n} from './Domain/Utility/Distance';\nexport { intersect } from './Domain/Utility/Intersect';\n","class TypeMapper {\n constructor(mapping = {}) {\n this.mapping = Object.keys(mapping)\n .map((key) => (value) => mapping[key](value) ? key : undefined)\n .concat((value) => typeof value);\n }\n map(value) {\n return this.mapping.reduce((carry, map) => carry || map(value), undefined);\n }\n}\n\nclass ValueMapper {\n constructor(types = new TypeMapper(), mapping = {}) {\n this.types = types;\n this.mapping = mapping;\n }\n map(value) {\n const type = this.types.map(value);\n const map = (value) => this.map(value);\n return type in this.mapping\n ? this.mapping[type](value, map)\n : (value === null || value === void 0 ? void 0 : value.toString()) || 'undefined';\n }\n}\n\nconst types = new TypeMapper({\n date: (value) => value instanceof Date,\n regexp: (value) => value instanceof RegExp,\n array: (value) => Array.isArray(value),\n null: (value) => value === null,\n});\nconst stringifier = new ValueMapper(types, {\n string: (value) => value ? `\"${value}\"` : 'EmptyString',\n date: (value, map) => map(value.toISOString()),\n object: (value, map) => {\n const string = String(value);\n if (/^\\[([a-z]+) \\1\\]$/i.test(string)) {\n const mapped = Object.keys(value)\n .map((key) => `${key}:${map(value[key])}`);\n return `{${mapped.join(',')}}`;\n }\n return string;\n },\n array: (value, map) => `[${value.map(map).join(',')}]`,\n null: () => 'NULL',\n undefined: () => 'Undefined',\n function: (value) => {\n const { constructor: { name: cname }, name } = value;\n const [, async, generator, func] = cname.match(/^(async)?(generator)?(function)$/i);\n const [, stype, sname] = value.toString().match(/^(?:async)?(?:[\\s\\*]+)?(class|function)?(?:[\\s\\*]+)?([a-z_]\\w*)?\\s*[\\(\\{]?/i);\n const parts = []\n .concat(stype && !(name || sname) ? 'anonymous' : [])\n .concat(name && !stype && sname ? 'shorthand' : [])\n .concat(async || [], generator || [])\n .concat(!(stype || sname) ? 'arrow' : [])\n .concat(stype || func)\n .map((key) => key[0].toUpperCase() + key.slice(1));\n return [parts.join('')].concat(name || []).join(' ');\n },\n});\nconst stringify = (value) => stringifier.map(value);\n\nclass AssertionError extends Error {\n constructor(message, value, trigger) {\n super(message);\n this.value = value;\n this.trigger = trigger;\n Object.setPrototypeOf(this, new.target.prototype);\n }\n get reasons() {\n const { message, value, trigger } = this;\n return ((trigger === null || trigger === void 0 ? void 0 : trigger.reasons) || []).concat(`${stringify(value)} ${message}`);\n }\n get cause() {\n const { message, value, trigger } = this;\n return [{ value, message }].concat((trigger === null || trigger === void 0 ? void 0 : trigger.cause) || []);\n }\n get reason() {\n return String(this);\n }\n toString(separator = '\\u200b\\u2190\\u200b') {\n return this.reasons\n .reverse()\n .join(separator);\n }\n}\n\n/**\n * Create a guard verifying the given value matches the specified type\n */\nfunction is(type) {\n return (value) => typeof value === type;\n}\n/**\n * Create a guard verifying the given value matches any of the validators\n */\nfunction any(...checks) {\n return (value) => checks.some((check) => check(value));\n}\n/**\n * Create a guard verifying the given value matches all of the validators\n */\nfunction all(...checks) {\n return (value) => checks.every((check) => check(value));\n}\n/**\n * Create a guard verifying the given value matches none of the validators\n */\nfunction not(...checks) {\n return (value) => checks.every((check) => !check(value));\n}\n\n/**\n * Guard verifying the value is a array\n */\nconst isArray = (value) => Array.isArray(value);\n/**\n * Guard verifying the value is a bigint\n */\nconst isBigInt = is('bigint');\n/**\n * Guard verifying the value is a boolean\n */\nconst isBoolean = is('boolean');\n/**\n * Guard verifying the value is a function\n */\nconst isFunction = is('function');\n/**\n * Guard verifying the value is a null\n */\nconst isNULL = (value) => value === null;\n/**\n * Guard verifying the value is a number\n */\nconst isNumber = is('number');\n/**\n * Guard verifying the value is a object\n */\nconst isObject = all(not(isArray), not(isNULL), is('object'));\n/**\n * Guard verifying the value is a string\n */\nconst isString = is('string');\n/**\n * Guard verifying the value is a symbol\n */\nconst isSymbol = is('symbol');\n/**\n * Guard verifying the value is a undefined\n */\nconst isUndefined = is('undefined');\n\n/**\n * Guard verifying the value to be an array containing only elements matching the validators\n */\nfunction isArrayOfType(...validators) {\n const check = all(...validators);\n return all(isArray, (value) => value.every(check));\n}\n/**\n * Guard verifying the value to be an array with a length between the given boundaries\n */\nfunction isArrayOfSize(min, max = Infinity) {\n return all(isArray, (value) => value.length >= min && value.length <= max);\n}\n\n/**\n * Create an assertion guard, throwing an AssertionError with the provided message if any validator failes\n */\nfunction assertion(message, ...rules) {\n const valid = all(...rules);\n // create an extend of AssertionError which is a unique value for each assertion\n // this allows for easy recognition whether the AssertionError was thrown from this\n // or other assertions\n class InnerAssertionError extends AssertionError {\n }\n return (value) => {\n try {\n // validity may throw an error and end up in the catch block\n if (!valid(value)) {\n // if not valid (and not thrown) throw an InnerAssertionError\n throw new InnerAssertionError(message, value);\n }\n }\n catch (error) {\n // the caught error is passed on as origin to a new AssertionError only\n // if it was thrown from the valid checker function\n const rest = error instanceof InnerAssertionError || !(error instanceof AssertionError)\n ? []\n : [error];\n throw new AssertionError(message, value, ...rest);\n }\n return true;\n };\n}\n/**\n * Guard asserting the given value to match the conditions or throw an AssertionError otherwise\n */\nfunction assert(value, message, ...rules) {\n const validate = assertion(message, ...rules);\n return validate(value);\n}\n\n/**\n * Guard verifying the value to be an integer number\n */\nfunction isInteger(value) {\n return Number.isSafeInteger(value);\n}\n/**\n * Guard verifying the value to be a float number\n */\nfunction isFloat(value) {\n return !Number.isInteger(value);\n}\n/**\n * Guard verifying the value to be a positive number\n */\nfunction isPositive(value) {\n return isNumber(value) && value > 0;\n}\n/**\n * Guard verifying the value to be a negative number\n */\nfunction isNegative(value) {\n return isNumber(value) && value < 0;\n}\n/**\n * Create a guard matching numbers greater than the provided value\n */\nfunction isGreater(than) {\n return (value) => isNumber(value) && value > than;\n}\n/**\n * Create a guard matching numbers less than the provided value\n */\nfunction isLess(than) {\n return (value) => isNumber(value) && value < than;\n}\n/**\n * Create a guard matching numbers greater than or equal to the provided value\n */\nfunction isGreaterOrEqual(than) {\n return (value) => isNumber(value) && value >= than;\n}\n/**\n * Create a guard matching numbers less than or equal to the provided value\n */\nfunction isLessOrEqual(than) {\n return (value) => isNumber(value) && value <= than;\n}\n\n/**\n * Creates a guard verifying the value is an object and has the given key\n */\nfunction isKey(key) {\n return all(isObject, (value) => key in value);\n}\n/**\n * Creates a guard verifying the value is an object and has the given key matching the validators\n */\nfunction isKeyOfType(key, ...validators) {\n return all(isKey(key), (value) => validators.every((check) => check(value[key])));\n}\n/**\n * Creates a guard verifying the value is an object and doesn't have the key or has the given key matching the validators\n */\nfunction isOptionalKeyOfType(key, ...validators) {\n return any(all(isObject, not(isKey(key))), isKeyOfType(key, ...validators));\n}\n/**\n * Creates a guard verifying the value is an object matching at least the structure\n */\nfunction isStructure(struct, ...options) {\n const optional = options.reduce((carry, key) => carry.concat(key), []);\n const validators = Object.keys(struct)\n .map((key) => (optional.includes(key) ? isOptionalKeyOfType : isKeyOfType)(key, struct[key]));\n return all(isObject, ...validators);\n}\n/**\n * Creates a guard verifying the value is an object matching exactly the structure\n */\nfunction isStrictStructure(struct, ...options) {\n const keys = Object.keys(struct);\n return all(\n // do the keys present match the given structure conditions\n isStructure(struct, ...options), \n // every key should be part of the structure\n (value) => Object.keys(value).every((key) => keys.includes(key)));\n}\n/**\n * Creates a guard verifying the value is an object and an instance of the given class\n */\nfunction isInstanceOf(type) {\n return (value) => value instanceof type;\n}\n\n/**\n * Guard verifying the value to be a string which matches the given pattern\n */\nfunction isStringWithPattern(pattern) {\n return all(isString, (value) => pattern.test(value));\n}\n\nexport { AssertionError, all, any, assert, assertion, is, isArray, isArrayOfSize, isArrayOfType, isBigInt, isBoolean, isFloat, isFunction, isGreater, isGreaterOrEqual, isInstanceOf, isInteger, isKey, isKeyOfType, isLess, isLessOrEqual, isNULL, isNegative, isNumber, isObject, isOptionalKeyOfType, isPositive, isStrictStructure, isString, isStringWithPattern, isStructure, isSymbol, isUndefined, not };\n","import { type Guard, isArray, type Validator } from '@konfirm/guard';\n\nexport function isTuple<T extends Array<unknown>>(\n\t...rules: Array<Validator>\n): Guard<T> {\n\treturn (value: unknown): value is T =>\n\t\tisArray(value) &&\n\t\tvalue.length === rules.length &&\n\t\trules.every((rule, index) => rule(value[index]));\n}\n","export const EARTH_RADIUS = 6_371_008.7714; // mean radius\nexport const EARTH_RADIUS_MAJOR = 6_378_137; // equatorial radius\nexport const EARTH_RADIUS_MINOR = 6_356_752.314_245; // semiminor axis\nexport const EARTH_FLATTENING = 298.257_223_563;\nexport const GPS_SATELLITE_ORBIT = 20_180_000;\n","import { type Guard, isNumber } from '@konfirm/guard';\n\nexport function isNumberValue<T extends number>(value: unknown): value is T {\n\treturn isNumber(value) && Number.isFinite(value);\n}\n\nexport function isNumberBetween<T extends number>(\n\ta: number,\n\tb: number = Infinity,\n): Guard<T> {\n\tconst min = Math.min(a, b);\n\tconst max = Math.max(a, b);\n\n\treturn (value: unknown): value is T =>\n\t\tisNumberValue(value) && value >= min && value <= max;\n}\n","import { EARTH_RADIUS, GPS_SATELLITE_ORBIT } from '../../Constants';\nimport { isNumberBetween, isNumberValue } from '../../Guards/Number';\n\nexport type Altitude = number;\nexport function isAltitude(value: unknown): value is Altitude {\n\treturn isNumberValue(value);\n}\n\nexport const isStrictAltitude = isNumberBetween<Altitude>(\n\t-EARTH_RADIUS,\n\tGPS_SATELLITE_ORBIT,\n);\n","import { isNumberBetween, isNumberValue } from '../../Guards/Number';\n\nexport type Latitude = number;\nexport function isLatitude(value: unknown): value is Latitude {\n\treturn isNumberValue(value);\n}\nexport const isStrictLatitude = isNumberBetween<Latitude>(-90, 90);\n","import { isNumberBetween, isNumberValue } from '../../Guards/Number';\n\nexport type Longitude = number;\nexport function isLongitude(value: unknown): value is Longitude {\n\treturn isNumberValue(value);\n}\nexport const isStrictLongitude = isNumberBetween<Longitude>(-180, 180);\n","import { any } from '@konfirm/guard';\nimport { isTuple } from '../../Guards/Tuple';\nimport { type Altitude, isAltitude, isStrictAltitude } from './Altitude';\nimport { isLatitude, isStrictLatitude, type Latitude } from './Latitude';\nimport { isLongitude, isStrictLongitude, type Longitude } from './Longitude';\n\nexport type Position = [Longitude, Latitude, Altitude?, ...Array<unknown>];\nexport const isPosition = any<Position>(\n\tisTuple(isLongitude, isLatitude),\n\tisTuple(isLongitude, isLatitude, isAltitude),\n);\nexport const isStrictPosition = any<Position>(\n\tisTuple(isStrictLongitude, isStrictLatitude),\n\tisTuple(isStrictLongitude, isStrictLatitude, isStrictAltitude),\n);\nexport function isEquivalentPosition(one: unknown, two: unknown): boolean {\n\treturn (\n\t\tisPosition(one) &&\n\t\tisPosition(two) &&\n\t\tone.length === two.length &&\n\t\tone.every((v, i) => v === two[i])\n\t);\n}\n","import { all, any } from '@konfirm/guard';\nimport { isTuple } from '../../Guards/Tuple';\nimport { type Altitude, isAltitude, isStrictAltitude } from './Altitude';\nimport { isLatitude, isStrictLatitude, type Latitude } from './Latitude';\nimport { isLongitude, isStrictLongitude, type Longitude } from './Longitude';\n\nexport type BoundingBox =\n\t| [Longitude, Latitude, Altitude, Longitude, Latitude, Altitude]\n\t| [Longitude, Latitude, Longitude, Latitude];\nconst isBoundingBoxWithAltitude = all(\n\tisTuple(\n\t\tisLongitude,\n\t\tisLatitude,\n\t\tisAltitude,\n\t\tisLongitude,\n\t\tisLatitude,\n\t\tisAltitude,\n\t),\n\t([, s, , , n]) => s <= n,\n);\nconst isBoundingBoxWithoutAltitude = all(\n\tisTuple(isLongitude, isLatitude, isLongitude, isLatitude),\n\t([, s, , n]) => s <= n,\n);\nexport const isBoundingBox = any<BoundingBox>(\n\tisBoundingBoxWithAltitude,\n\tisBoundingBoxWithoutAltitude,\n);\nexport const isStrictBoundingBox = any<BoundingBox>(\n\tall(\n\t\tisTuple(\n\t\t\tisStrictLongitude,\n\t\t\tisStrictLatitude,\n\t\t\tisStrictAltitude,\n\t\t\tisStrictLongitude,\n\t\t\tisStrictLatitude,\n\t\t\tisStrictAltitude,\n\t\t),\n\t\tisBoundingBoxWithAltitude,\n\t),\n\tall(\n\t\tisTuple(\n\t\t\tisStrictLongitude,\n\t\t\tisStrictLatitude,\n\t\t\tisStrictLongitude,\n\t\t\tisStrictLatitude,\n\t\t),\n\t\tisBoundingBoxWithoutAltitude,\n\t),\n);\n","import { all, type Guard, isString, isStructure } from '@konfirm/guard';\nimport {\n\ttype BoundingBox,\n\tisBoundingBox,\n\tisStrictBoundingBox,\n} from './BoundingBox';\n\ntype GeoJSONBase = {\n\ttype: string;\n\tbbox?: BoundingBox;\n\t[key: string]: unknown;\n};\nexport type GeoJSONObject<T extends GeoJSONBase = GeoJSONBase> = GeoJSONBase &\n\tT;\nexport function isGeoJSONObject<T extends GeoJSONBase>(type: string): Guard<T> {\n\treturn isStructure<T>(\n\t\t{\n\t\t\ttype: all(isString, (value: unknown) => value === type),\n\t\t\tbbox: isBoundingBox,\n\t\t},\n\t\t'bbox',\n\t);\n}\nexport function isStrictGeoJSONObject<T extends GeoJSONBase>(\n\ttype: string,\n): Guard<T> {\n\treturn isStructure<T>(\n\t\t{\n\t\t\ttype: all(isString, (value: unknown) => value === type),\n\t\t\tbbox: isStrictBoundingBox,\n\t\t},\n\t\t'bbox',\n\t);\n}\n","import { all, type Guard, isKeyOfType, type Validator } from '@konfirm/guard';\nimport { type GeoJSONObject, isGeoJSONObject } from './Concept/GeoJSONObject';\n\ntype GeometryBase = GeoJSONObject & {\n\tcoordinates: Array<unknown>;\n};\n\nexport type GeometryObject<T extends GeometryBase> = Omit<\n\tGeometryBase,\n\t'coordinates'\n> &\n\tT;\nexport type MultiGeometryObject<T extends GeometryBase> = GeometryObject<{\n\ttype: `Multi${T['type']}`;\n\tcoordinates: Array<T['coordinates']>;\n}>;\nexport function isGeometryObject<T extends GeometryBase>(\n\ttype: string,\n\tisCoordinates: Validator,\n): Guard<T> {\n\treturn all<T>(\n\t\tisGeoJSONObject(type),\n\t\tisKeyOfType('coordinates', isCoordinates),\n\t);\n}\n","import type { Guard } from '@konfirm/guard';\nimport {\n\tisPosition,\n\tisStrictPosition,\n\ttype Position,\n} from '../Concept/Position';\nimport { type GeometryObject, isGeometryObject } from '../GeometryObject';\n\nexport type Point = GeometryObject<{\n\ttype: 'Point';\n\tcoordinates: Position;\n}>;\nexport const isPointCoordinates: Guard<Point['coordinates']> = isPosition;\nexport const isPoint: Guard<Point> = isGeometryObject<Point>(\n\t'Point',\n\tisPointCoordinates,\n);\nexport const isStrictPointCoordinates: Guard<Point['coordinates']> =\n\tisStrictPosition;\nexport const isStrictPoint: Guard<Point> = isGeometryObject<Point>(\n\t'Point',\n\tisStrictPointCoordinates,\n);\n","import { type Guard, isArrayOfType } from '@konfirm/guard';\nimport { isGeometryObject, type MultiGeometryObject } from '../GeometryObject';\nimport {\n\tisPointCoordinates,\n\tisStrictPointCoordinates,\n\ttype Point,\n} from './Point';\n\nexport type MultiPoint = MultiGeometryObject<Point>;\nexport const isMultiPointCoordinates: Guard<MultiPoint['coordinates']> =\n\tisArrayOfType(isPointCoordinates);\nexport const isMultiPoint = isGeometryObject<MultiPoint>(\n\t'MultiPoint',\n\tisMultiPointCoordinates,\n);\nexport const isStrictMultiPointCoordinates: Guard<MultiPoint['coordinates']> =\n\tisArrayOfType(isStrictPointCoordinates);\nexport const isStrictMultiPoint = isGeometryObject<MultiPoint>(\n\t'MultiPoint',\n\tisStrictMultiPointCoordinates,\n);\n","import type { Guard } from '@konfirm/guard';\nimport { type GeometryObject, isGeometryObject } from '../GeometryObject';\nimport {\n\tisMultiPointCoordinates,\n\tisStrictMultiPointCoordinates,\n\ttype MultiPoint,\n} from './MultiPoint';\n\nexport type LineString = GeometryObject<{\n\ttype: 'LineString';\n\tcoordinates: MultiPoint['coordinates'];\n}>;\nexport const isLineStringCoordinates = isMultiPointCoordinates;\nexport const isLineString: Guard<LineString> = isGeometryObject<LineString>(\n\t'LineString',\n\tisLineStringCoordinates,\n);\nexport const isStrictLineStringCoordinates = isStrictMultiPointCoordinates;\nexport const isStrictLineString: Guard<LineString> =\n\tisGeometryObject<LineString>('LineString', isStrictLineStringCoordinates);\n","import { isArrayOfType } from '@konfirm/guard';\nimport { isGeometryObject, type MultiGeometryObject } from '../GeometryObject';\nimport {\n\tisLineStringCoordinates,\n\tisStrictLineStringCoordinates,\n\ttype LineString,\n} from './LineString';\n\nexport type MultiLineString = MultiGeometryObject<LineString>;\nexport const isMultiLineStringCoordinates = isArrayOfType(\n\tisLineStringCoordinates,\n);\nexport const isMultiLineString = isGeometryObject<MultiLineString>(\n\t'MultiLineString',\n\tisMultiLineStringCoordinates,\n);\nexport const isStrictMultiLineStringCoordinates = isArrayOfType(\n\tisStrictLineStringCoordinates,\n);\nexport const isStrictMultiLineString = isGeometryObject<MultiLineString>(\n\t'MultiLineString',\n\tisStrictMultiLineStringCoordinates,\n);\n","import { isArrayOfType } from '@konfirm/guard';\nimport { isPosition, type Position } from '../GeoJSON/Concept/Position';\n\n// Standard shoelace formula: positive = CCW (RFC 7946 exterior), negative = CW (hole).\nfunction shoelace(positions: Array<Position>): number {\n\treturn positions.reduce((carry, [x, y], i, a) => {\n\t\tconst [nx, ny] = a[(i + 1) % a.length];\n\n\t\treturn carry + (x * ny - nx * y);\n\t}, 0);\n}\n\nconst isPositionArray = isArrayOfType<Array<Position>>(isPosition);\n\nexport function isClockwiseWinding<T extends Array<Position>>(\n\tvalue: unknown,\n): value is T {\n\treturn isPositionArray(value) && shoelace(value) <= 0;\n}\nexport function isCounterClockwiseWinding<T extends Array<Position>>(\n\tvalue: unknown,\n): value is T {\n\treturn isPositionArray(value) && shoelace(value) >= 0;\n}\n","import { all, isArrayOfSize, isArrayOfType } from '@konfirm/guard';\nimport { isPosition, isStrictPosition, type Position } from './Position';\n\nexport type LinearRing = Array<Position>;\nexport const isLinearRing = all<LinearRing>(\n\tisArrayOfType(isPosition),\n\tisArrayOfSize(4),\n\t(value: Array<Position>) =>\n\t\tvalue[value.length - 1].every((v, i) => v === value[0][i]),\n);\nexport const isStrictLinearRing = all<LinearRing>(\n\tisArrayOfType(isStrictPosition),\n\tisArrayOfSize(4),\n\t(value: Array<Position>) =>\n\t\tvalue[value.length - 1].every((v, i) => v === value[0][i]),\n);\n","import { all } from '@konfirm/guard';\nimport { isCounterClockwiseWinding } from '../../Utility/Winding';\nimport {\n\tisLinearRing,\n\tisStrictLinearRing,\n\ttype LinearRing,\n} from './LinearRing';\n\nexport type ExteriorRing = LinearRing;\nexport const isExteriorRing = all<ExteriorRing>(isLinearRing);\nexport const isStrictExteriorRing = all<ExteriorRing>(\n\tisStrictLinearRing,\n\tisCounterClockwiseWinding,\n);\n","import { all } from '@konfirm/guard';\nimport { isClockwiseWinding } from '../../Utility/Winding';\nimport {\n\tisLinearRing,\n\tisStrictLinearRing,\n\ttype LinearRing,\n} from './LinearRing';\n\nexport type InteriorRing = LinearRing;\nexport const isInteriorRing = all<InteriorRing>(isLinearRing);\nexport const isStrictInteriorRing = all<InteriorRing>(\n\tisStrictLinearRing,\n\tisClockwiseWinding,\n);\n","import { all, isArrayOfType } from '@konfirm/guard';\nimport {\n\ttype ExteriorRing,\n\tisStrictExteriorRing,\n} from '../Concept/ExteriorRing';\nimport {\n\ttype InteriorRing,\n\tisStrictInteriorRing,\n} from '../Concept/InteriorRing';\nimport { isLinearRing, isStrictLinearRing } from '../Concept/LinearRing';\nimport { type GeometryObject, isGeometryObject } from '../GeometryObject';\n\nexport type Polygon = GeometryObject<{\n\ttype: 'Polygon';\n\tcoordinates: [ExteriorRing, ...Array<InteriorRing>];\n}>;\nexport const isPolygonCoordinates = all(isArrayOfType(isLinearRing));\nexport const isPolygon = isGeometryObject<Polygon>(\n\t'Polygon',\n\tisPolygonCoordinates,\n);\nexport const isStrictPolygonCoordinates = all(\n\tisArrayOfType(isStrictLinearRing),\n\t(value: unknown) => isStrictExteriorRing((<Array<unknown>>value)[0]),\n\t(value: unknown) =>\n\t\t(<Array<unknown>>value).slice(1).every(isStrictInteriorRing),\n);\nexport const isStrictPolygon = isGeometryObject<Polygon>(\n\t'Polygon',\n\tisStrictPolygonCoordinates,\n);\n","import { isArrayOfType } from '@konfirm/guard';\nimport { isGeometryObject, type MultiGeometryObject } from '../GeometryObject';\nimport {\n\tisPolygonCoordinates,\n\tisStrictPolygonCoordinates,\n\ttype Polygon,\n} from './Polygon';\n\nexport type MultiPolygon = MultiGeometryObject<Polygon>;\nexport const isMultiPolygonCoordinates = isArrayOfType(isPolygonCoordinates);\nexport const isMultiPolygon = isGeometryObject<MultiPolygon>(\n\t'MultiPolygon',\n\tisMultiPolygonCoordinates,\n);\nexport const isStrictMultiPolygonCoordinates = isArrayOfType(\n\tisStrictPolygonCoordinates,\n);\nexport const isStrictMultiPolygon = isGeometryObject<MultiPolygon>(\n\t'MultiPolygon',\n\tisStrictMultiPolygonCoordinates,\n);\n","import {\n\tall,\n\tany,\n\ttype Guard,\n\tisArrayOfType,\n\tisKeyOfType,\n} from '@konfirm/guard';\nimport { type GeoJSONObject, isGeoJSONObject } from './Concept/GeoJSONObject';\n\nimport {\n\tisLineString,\n\tisStrictLineString,\n\ttype LineString,\n} from './Geometry/LineString';\nimport {\n\tisMultiLineString,\n\tisStrictMultiLineString,\n\ttype MultiLineString,\n} from './Geometry/MultiLineString';\nimport {\n\tisMultiPoint,\n\tisStrictMultiPoint,\n\ttype MultiPoint,\n} from './Geometry/MultiPoint';\nimport {\n\tisMultiPolygon,\n\tisStrictMultiPolygon,\n\ttype MultiPolygon,\n} from './Geometry/MultiPolygon';\nimport { isPoint, isStrictPoint, type Point } from './Geometry/Point';\nimport { isPolygon, isStrictPolygon, type Polygon } from './Geometry/Polygon';\n\nexport type GeometryPrimitive =\n\t| Point\n\t| MultiPoint\n\t| LineString\n\t| MultiLineString\n\t| Polygon\n\t| MultiPolygon;\n\nexport const isGeometryPrimitive = any<GeometryPrimitive>(\n\tisPoint,\n\tisMultiPoint,\n\tisLineString,\n\tisMultiLineString,\n\tisPolygon,\n\tisMultiPolygon,\n);\n\nexport const isStrictGeometryPrimitive = any<GeometryPrimitive>(\n\tisStrictPoint,\n\tisStrictMultiPoint,\n\tisStrictLineString,\n\tisStrictMultiLineString,\n\tisStrictPolygon,\n\tisStrictMultiPolygon,\n);\n\nexport type GeometryCollection<\n\tG extends GeometryPrimitive = GeometryPrimitive,\n> = GeoJSONObject<{\n\ttype: 'GeometryCollection';\n\tgeometries: Array<G | GeometryCollection<G>>;\n}>;\n\nexport type Geometry = GeometryPrimitive | GeometryCollection;\n\nexport const isGeometry = any<Geometry>(\n\tisGeometryPrimitive,\n\tisGeometryCollection,\n);\n\nexport const isStrictGeometry = any<Geometry>(\n\tisStrictGeometryPrimitive,\n\tisStrictGeometryCollection,\n);\n\nconst isGeometryCollectionObject = all<GeometryCollection>(\n\tisGeoJSONObject('GeometryCollection'),\n\tisKeyOfType('geometries', isArrayOfType(isGeometry)),\n);\n\nconst isStrictGeometryCollectionObject = all<GeometryCollection>(\n\tisGeoJSONObject('GeometryCollection'),\n\tisKeyOfType('geometries', isArrayOfType(isStrictGeometry)),\n);\n\nexport function isGeometryCollection<\n\tG extends GeometryPrimitive = GeometryPrimitive,\n>(\n\tvalue: unknown,\n\tisG: Guard<G> = isGeometryPrimitive as Guard<G>,\n): value is GeometryCollection<G> {\n\treturn (\n\t\tisGeometryCollectionObject(value) &&\n\t\tvalue.geometries.every((g) => isG(g) || isGeometryCollection(g, isG))\n\t);\n}\n\nexport function isStrictGeometryCollection<\n\tG extends GeometryPrimitive = GeometryPrimitive,\n>(\n\tvalue: unknown,\n\tisG: Guard<G> = isStrictGeometryPrimitive as Guard<G>,\n): value is GeometryCollection<G> {\n\treturn (\n\t\tisStrictGeometryCollectionObject(value) &&\n\t\tvalue.geometries.every(\n\t\t\t(g) => isG(g) || isStrictGeometryCollection(g, isG),\n\t\t)\n\t);\n}\n","import {\n\tall,\n\tany,\n\ttype Guard,\n\tisNULL,\n\tisObject,\n\tisStructure,\n} from '@konfirm/guard';\nimport { type GeoJSONObject, isGeoJSONObject } from './Concept/GeoJSONObject';\nimport { type Geometry, isGeometry, isStrictGeometry } from './Geometry';\n\nexport type Feature<G extends Geometry | null = Geometry | null> =\n\tGeoJSONObject<{\n\t\ttype: 'Feature';\n\t\tgeometry: G;\n\t\tproperties: { [key: string]: unknown } | null;\n\t}>;\n\nconst isFeatureObject = all<Feature<Geometry | null>>(\n\tisGeoJSONObject('Feature'),\n\tisStructure({\n\t\tgeometry: any(isNULL, isGeometry),\n\t\tproperties: any(isNULL, isObject),\n\t}),\n);\nconst isStrictFeatureObject = all<Feature<Geometry | null>>(\n\tisGeoJSONObject('Feature'),\n\tisStructure({\n\t\tgeometry: any(isNULL, isStrictGeometry),\n\t\tproperties: any(isNULL, isObject),\n\t}),\n);\n\nexport function isFeature<G extends Geometry | null>(\n\tinput: unknown,\n\tisG: Guard<G> = any(isNULL, isGeometry),\n): input is Feature<G> {\n\treturn isFeatureObject(input) && isG(input.geometry);\n}\n\nexport function isStrictFeature<G extends Geometry | null>(\n\tinput: unknown,\n\tisG: Guard<G> = any(isNULL, isStrictGeometry),\n): input is Feature<G> {\n\treturn isStrictFeatureObject(input) && isG(input.geometry);\n}\n","import {\n\tall,\n\tany,\n\ttype Guard,\n\tisArrayOfType,\n\tisKeyOfType,\n\tisNULL,\n} from '@konfirm/guard';\nimport { type GeoJSONObject, isGeoJSONObject } from './Concept/GeoJSONObject';\nimport { type Feature, isFeature, isStrictFeature } from './Feature';\nimport { type Geometry, isGeometry } from './Geometry';\n\nexport type FeatureCollection<G extends Geometry | null = Geometry | null> =\n\tGeoJSONObject<{\n\t\ttype: 'FeatureCollection';\n\t\tfeatures: Array<Feature<G>>;\n\t}>;\n\nconst isFeatureCollectionObject = all<FeatureCollection>(\n\tisGeoJSONObject('FeatureCollection'),\n\tisKeyOfType('features', isArrayOfType(isFeature)),\n);\nconst isStrictFeatureCollectionObject = all<FeatureCollection>(\n\tisGeoJSONObject('FeatureCollection'),\n\tisKeyOfType('features', isArrayOfType(isStrictFeature)),\n);\n\nexport function isFeatureCollection<G extends Geometry | null>(\n\tvalue: unknown,\n\tisG: Guard<G> = any(isNULL, isGeometry),\n): value is FeatureCollection<G> {\n\treturn (\n\t\tisFeatureCollectionObject(value) &&\n\t\tvalue.features.every((feature) => isFeature(feature, isG))\n\t);\n}\n\nexport function isStrictFeatureCollection<G extends Geometry | null>(\n\tvalue: unknown,\n\tisG: Guard<G> = any(isNULL, isGeometry),\n): value is FeatureCollection<G> {\n\treturn (\n\t\tisStrictFeatureCollectionObject(value) &&\n\t\tvalue.features.every((feature) => isStrictFeature(feature, isG))\n\t);\n}\n","import { any } from '@konfirm/guard';\nimport { type Feature, isFeature, isStrictFeature } from './Feature';\nimport {\n\ttype FeatureCollection,\n\tisFeatureCollection,\n\tisStrictFeatureCollection,\n} from './FeatureCollection';\nimport {\n\ttype Geometry,\n\ttype GeometryCollection,\n\tisGeometry,\n\tisGeometryCollection,\n\tisStrictGeometry,\n\tisStrictGeometryCollection,\n} from './Geometry';\n\nexport type GeoJSON =\n\t| Geometry\n\t| GeometryCollection\n\t| Feature\n\t| FeatureCollection;\nexport const isGeoJSON = any<GeoJSON>(\n\tisGeometry,\n\tisGeometryCollection,\n\tisFeature,\n\tisFeatureCollection,\n);\nexport const isStrictGeoJSON = any<GeoJSON>(\n\tisStrictGeometry,\n\tisStrictGeometryCollection,\n\tisStrictFeature,\n\tisStrictFeatureCollection,\n);\n","import type {\n\tLineString,\n\tMultiLineString,\n\tMultiPoint,\n\tMultiPolygon,\n\tPoint,\n\tPolygon,\n} from '../../main';\nimport type { Feature } from '../GeoJSON/Feature';\nimport type { FeatureCollection } from '../GeoJSON/FeatureCollection';\nimport type { GeoJSON } from '../GeoJSON/GeoJSON';\nimport type { GeometryCollection } from '../GeoJSON/Geometry';\n\ntype SimpleGeometry = Point | LineString | Polygon;\ntype UnwrapGeometry = Exclude<GeoJSON, SimpleGeometry>;\n\ntype Reducer = {\n\t[K in UnwrapGeometry['type']]: (\n\t\tgeo: Extract<UnwrapGeometry, { type: K }>,\n\t\tunwrap: (geo: GeoJSON) => Iterable<SimpleGeometry>,\n\t) => Iterable<SimpleGeometry>;\n};\n\nconst reducers: Reducer = {\n\t*MultiPoint(\n\t\t{ coordinates, ...rest }: MultiPoint,\n\t\tunwrap,\n\t): Iterable<SimpleGeometry> {\n\t\tfor (const pair of coordinates) {\n\t\t\tyield* unwrap(<Point>{\n\t\t\t\tcoordinates: pair,\n\t\t\t\t...rest,\n\t\t\t\ttype: 'Point',\n\t\t\t});\n\t\t}\n\t},\n\t*MultiLineString(\n\t\t{ coordinates, ...rest }: MultiLineString,\n\t\tunwrap,\n\t): Iterable<SimpleGeometry> {\n\t\tfor (const pair of coordinates) {\n\t\t\tyield* unwrap(<LineString>{\n\t\t\t\tcoordinates: pair,\n\t\t\t\t...rest,\n\t\t\t\ttype: 'LineString',\n\t\t\t});\n\t\t}\n\t},\n\t*MultiPolygon(\n\t\t{ coordinates, ...rest }: MultiPolygon,\n\t\tunwrap,\n\t): Iterable<SimpleGeometry> {\n\t\tfor (const pair of coordinates) {\n\t\t\tyield* unwrap(<Polygon>{\n\t\t\t\tcoordinates: pair,\n\t\t\t\t...rest,\n\t\t\t\ttype: 'Polygon',\n\t\t\t});\n\t\t}\n\t},\n\t*GeometryCollection(\n\t\t{ geometries }: GeometryCollection,\n\t\tunwrap,\n\t): Iterable<SimpleGeometry> {\n\t\tfor (const geometry of geometries) {\n\t\t\tyield* unwrap(geometry);\n\t\t}\n\t},\n\t*Feature({ geometry }: Feature, unwrap): Iterable<SimpleGeometry> {\n\t\tif (geometry) {\n\t\t\tyield* unwrap(geometry);\n\t\t}\n\t},\n\t*FeatureCollection(\n\t\t{ features }: FeatureCollection,\n\t\tunwrap,\n\t): Iterable<SimpleGeometry> {\n\t\tfor (const { geometry } of features) {\n\t\t\tif (geometry) {\n\t\t\t\tyield* unwrap(geometry);\n\t\t\t}\n\t\t}\n\t},\n};\n\n/**\n * Iterator class to turn any GeoJSON structure into one or more SimpleGeometry (Point | LineString | Polygon) objects\n *\n * @export\n * @class SimpleGeometryIterator\n */\nexport class SimpleGeometryIterator {\n\tprivate readonly inputs: Array<GeoJSON> = [];\n\n\tconstructor(...inputs: [GeoJSON, ...Array<GeoJSON>]) {\n\t\tthis.inputs = inputs;\n\t}\n\n\t/**\n\t * Generator yielding all SimpleGeometry objects from the provided GeoJSON structure(s)\n\t *\n\t * @return {*} {Iterator<SimpleGeometry>}\n\t * @memberof SimpleGeometryIterator\n\t */\n\t*[Symbol.iterator](): Iterator<SimpleGeometry> {\n\t\tfor (const input of this.inputs) {\n\t\t\tfor (const simple of this.unwrap(input)) {\n\t\t\t\tyield simple;\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * unwrap any GeoJSON object into one or more SimpleGeometry object\n\t *\n\t * @private\n\t * @param {GeoJSON} geo\n\t * @return {*} {Iterable<SimpleGeometry>}\n\t * @memberof SimpleGeometryIterator\n\t */\n\tprivate *unwrap(geo: GeoJSON): Iterable<SimpleGeometry> {\n\t\ttype Invoke = (\n\t\t\tgeo: GeoJSON,\n\t\t\tunwrap: (geo: GeoJSON) => Iterable<SimpleGeometry>,\n\t\t) => Iterable<SimpleGeometry>;\n\t\tgeo.type in reducers\n\t\t\t? yield* (<Invoke>reducers[<keyof Reducer>geo.type])(\n\t\t\t\t\tgeo,\n\t\t\t\t\t(g: GeoJSON): Iterable<SimpleGeometry> => this.unwrap(g),\n\t\t\t\t)\n\t\t\t: yield <SimpleGeometry>geo;\n\t}\n}\n","/**\n * Iterator class which traverses all value pairs of two or more Iterable instances\n *\n * @export\n * @class IterablePairIterator\n * @template T\n */\nexport class IterablePairIterator<T = unknown> {\n\tprivate readonly iterators: Array<Iterable<T>> = [];\n\n\t/**\n\t * Constructs a new instance of IterablePairIterator\n\t *\n\t * @param iterators\n\t */\n\tconstructor(\n\t\t...iterators: [Iterable<T>, Iterable<T>, ...Array<Iterable<T>>]\n\t) {\n\t\tthis.iterators = iterators;\n\t}\n\n\t/**\n\t * Generator yielding all value pairs from the provided iterators\n\t *\n\t * @return {*} {Iterator<[T, T]>}\n\t * @memberof IterablePairIterator\n\t */\n\t*[Symbol.iterator](): Iterator<[T, T]> {\n\t\tfor (const [a, b] of this.pairs(this.iterators)) {\n\t\t\tfor (const one of a) {\n\t\t\t\tfor (const two of b) {\n\t\t\t\t\tyield [one, two];\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Create unique Iterator<T> combinations to traverse over\n\t *\n\t * @private\n\t * @param {Array<Iterable<T>>} source\n\t * @return {*} {Array<[Iterable<T>, Iterable<T>]>}\n\t * @memberof IterablePairIterator\n\t */\n\tprivate pairs(\n\t\tsource: Array<Iterable<T>>,\n\t): Array<[Iterable<T>, Iterable<T>]> {\n\t\treturn source.flatMap((a, i) =>\n\t\t\tsource.slice(i + 1).map((b) => [a, b]),\n\t\t) as Array<[Iterable<T>, Iterable<T>]>;\n\t}\n}\n","import type { GeoJSON } from '../GeoJSON/GeoJSON';\nimport type { Point } from '../GeoJSON/Geometry/Point';\nimport { SimpleGeometryIterator } from '../Iterator/SimpleGeometry';\n\nexport type Box = [\n\tminLon: number,\n\tminLat: number,\n\tmaxLon: number,\n\tmaxLat: number,\n];\n\nfunction* positions(\n\tcoordinates: Array<unknown>,\n): Generator<Point['coordinates']> {\n\tif (typeof coordinates[0] === 'number') {\n\t\tyield coordinates as Point['coordinates'];\n\t} else {\n\t\tfor (const child of coordinates as Array<Array<unknown>>) {\n\t\t\tyield* positions(child);\n\t\t}\n\t}\n}\n\nfunction boxFromPositions(source: Iterable<Point['coordinates']>): Box {\n\tlet minLon = Infinity,\n\t\tminLat = Infinity,\n\t\tmaxLon = -Infinity,\n\t\tmaxLat = -Infinity;\n\n\tfor (const [lon, lat] of source) {\n\t\tif (lon < minLon) minLon = lon;\n\t\tif (lat < minLat) minLat = lat;\n\t\tif (lon > maxLon) maxLon = lon;\n\t\tif (lat > maxLat) maxLat = lat;\n\t}\n\n\treturn [minLon, minLat, maxLon, maxLat];\n}\n\nexport function createBoxFromCoordinates(coordinates: Array<unknown>): Box {\n\treturn boxFromPositions(positions(coordinates));\n}\n\nexport function createBox(shape: GeoJSON): Box {\n\treturn boxFromPositions(\n\t\t(function* () {\n\t\t\tfor (const geometry of new SimpleGeometryIterator(shape)) {\n\t\t\t\tyield* positions(\n\t\t\t\t\t(geometry as unknown as { coordinates: Array<unknown> })\n\t\t\t\t\t\t.coordinates,\n\t\t\t\t);\n\t\t\t}\n\t\t})(),\n\t);\n}\n\nexport function isWithinBox(\n\t[lon, lat]: Point['coordinates'],\n\t[minLon, minLat, maxLon, maxLat]: Box,\n): boolean {\n\treturn lon >= minLon && lon <= maxLon && lat >= minLat && lat <= maxLat;\n}\n","export function values<T>(_: unknown, ...values: Array<T>): Array<T> {\n\treturn values;\n}\n","export function squared(n: number): number {\n\treturn n * n;\n}\n\nexport function bounds<T extends number>(\n\ta: number,\n\tb: number,\n): (value: number) => T {\n\tconst min = Math.min(a, b);\n\tconst max = Math.max(a, b);\n\tconst range = max - min;\n\tconst mod = (value: number): T =>\n\t\tvalue < min\n\t\t\t? mod(value + range)\n\t\t\t: value > max\n\t\t\t\t? mod(value - range)\n\t\t\t\t: <T>value;\n\n\treturn (value: number): T => mod(value) as T;\n}\n","/**\n * Inverse geodesic distance on WGS84 using Karney's algorithm.\n * Reference: Karney (2013) \"Algorithms for geodesics\", J. Geodesy 87:43–55\n * Series coefficients adapted from GeographicLib (MIT) by Charles F. F. Karney\n *\n * Notation used throughout (follows the paper):\n * β – parametric (reduced) latitude: tan β = (1−f) tan φ\n * α – azimuth of the geodesic\n * α₀ – equatorial azimuth\n * σ – arc length on the auxiliary sphere\n * ω – longitude on the auxiliary sphere\n * Λ – longitude difference on the ellipsoid\n * ε – series parameter: k² / (2(1+√(1+k²)) + k²), where k² = cos²α₀ · e′²\n * n – third flattening: f / (2−f)\n * e′²– second eccentricity squared: (a²−b²) / b²\n *\n * Prefix conventions: s = sin, c = cos, d = √(1 + e′² sin²β)\n * Subscript 1/2 = point 1 / point 2; 12 = quantity at point 2 minus point 1\n */\nimport type { Position } from '../../Domain/GeoJSON/Concept/Position';\nimport { EARTH_FLATTENING, EARTH_RADIUS_MAJOR } from '../Constants';\nimport { values } from './Common';\nimport { squared } from './Numeric';\n\n// ── WGS84 ──────────────────────────────────────────────────────────────────\nconst a = EARTH_RADIUS_MAJOR; // equatorial radius, m\nconst f = 1 / EARTH_FLATTENING; // flattening ≈ 1/298.257 (oblate, f > 0)\n// If f ever becomes negative (prolate ellipsoid), search for\n// \"Prolate ellipsoid (f < 0)\" in this file to find the three branches\n// that need to be restored and tested.\nconst f1 = 1 - f; // (1 − f)\nconst n = f / (2 - f); // third flattening\nconst b = a * f1; // semi-minor axis, m\nconst ep2 = (f * (2 - f)) / (f1 * f1); // e′²\nconst D2R = Math.PI / 180;\n\n// ── Tolerances ─────────────────────────────────────────────────────────────\nconst TINY = Number.EPSILON;\nconst TOL0 = Number.EPSILON;\nconst TOL1 = 200 * TOL0;\nconst TOL2 = Math.sqrt(TOL0);\nconst TOLB = TOL0 * TOL2;\nconst XTHRESH = 1000 * TOL2;\nconst MAXIT1 = 20;\nconst MAXIT2 = MAXIT1 + 80;\nconst ETOL2 =\n\t(0.1 * TOL2) /\n\tMath.sqrt((Math.max(0.001, Math.abs(f)) * Math.min(1, 1 - f / 2)) / 2);\n\nconst ORDER = 6; // series truncation order\n\n// ── Series coefficient arrays (Karney 2013, Table 1) ──────────────────────\n// Each block encodes polynomial-in-ε² coefficients followed by a denominator.\n// Evaluated by polyval(); A3/C3 arrays are further reduced to polynomials in n\n// at module load time by buildA3x/buildC3x.\n\n// A₁ − 1: (1−ε)·A₁ − 1 as polynomial in ε² (eq. 17)\nconst A1M1_COEFF = [1, 4, 64, 0, 256];\n\n// C₁[l] / ε^l as polynomials in ε² (eq. 18)\nconst C1_COEFF = values`\n\t${-1} ${6} ${-16} ${32},\n\t${-9} ${64} ${-128} ${2048},\n\t ${9} ${-16} ${768}\n\t ${3} ${-5} ${512}\n\t${-7} ${1280}\n\t${-7} ${2048}\n`;\n\n// A₂ − 1: (1+ε)·A₂ − 1 as polynomial in ε² (for reduced length m₁₂)\nconst A2M1_COEFF = [-11, -28, -192, 0, 256];\n\n// C₂[l] / ε^l as polynomials in ε²\nconst C2_COEFF = values`\n\t ${1} ${2} ${16} ${32}\n\t${35} ${64} ${384} ${2048}\n\t${15} ${80} ${768}\n\t ${7} ${35} ${512}\n\t${63} ${1280}\n\t${77} ${2048}\n`;\n\n// A₃ coefficients: polynomials in n for each power of ε (eq. 24)\nconst A3_COEFF = values`\n\t${-3} ${128}\n\t${-2} ${-3} ${64}\n\t${-1} ${-3} ${-1} ${16}\n\t ${3} ${-1} ${-2} ${8}\n\t ${1} ${-1} ${2}\n\t ${1} ${1}\n`;\n\n// C₃[l] coefficients: polynomials in n for each power of ε (eq. 25)\nconst C3_COEFF = values`\n\t ${3} ${128}\n\t ${2} ${5} ${128}\n \t ${-1} ${3} ${3} ${64}\n\t ${-1} ${0} ${1} ${8}\n\t ${-1} ${1} ${4}\n\t ${5} ${256}\n\t ${1} ${3} ${128}\n\t ${-3} ${-2} ${3} ${64}\n\t ${1} ${-3} ${2} ${32}\n\t ${7} ${512}\n\t${-10} ${9} ${384}\n\t ${5} ${-9} ${5} ${192}\n\t ${7} ${512}\n\t${-14} ${7} ${512}\n\t ${21} ${2560}\n`;\n\n// ── Low-level utilities ────────────────────────────────────────────────────\n// Avoids Math.hypot whose precision degrades on some engines for small values\nfunction hypot(x: number, y: number): number {\n\treturn Math.sqrt(x * x + y * y);\n}\nfunction copysign(x: number, y: number): number {\n\treturn Math.abs(x) * (y < 0 || (y === 0 && 1 / y < 0) ? -1 : 1);\n}\n// Horner's method: evaluates p[s]·x^N + p[s+1]·x^(N−1) + … + p[s+N]\nfunction polyval(N: number, p: Array<number>, s: number, x: number): number {\n\tlet i = s;\n\tlet n = N;\n\t// Oblate ellipsoid (f > 0, WGS84) — ORDER = 6 and all polynomial degrees are\n\t// non-negative, so N < 0 never occurs. Restore the guard if polyval is ever\n\t// called with a degree-(−1) polynomial (which must return 0 without consuming p[i]).\n\t// let y = n < 0 ? 0 : p[i++];\n\tlet y = p[i++];\n\twhile (n-- > 0) y = y * x + p[i++];\n\treturn y;\n}\nfunction angNormalize(x: number): number {\n\tconst v = x % 360;\n\treturn v <= -180 ? v + 360 : v > 180 ? v - 360 : v;\n}\n\n// Clenshaw summation for Σ c[k]·sin(2k·x) (sinp=true) or Σ c[k]·cos((2k+1)·x)\n// Oblate ellipsoid (f > 0, WGS84) — sinCosSeries is only called for the sine\n// series (sinp = true). The cosine variant (sinp = false) is unused. Restore the\n// sinp parameter and both branches if the cosine series is ever needed.\nfunction sinCosSeries(sinx: number, cosx: number, c: Array<number>): number {\n\t// sinp = true always: cn = k - 1, return = 2·sinx·cosx·y0\n\tlet k = c.length;\n\tlet cn = k - 1;\n\tconst ar = 2 * (cosx - sinx) * (cosx + sinx); // 2·cos(2x)\n\tlet y0 = cn & 1 ? c[--k] : 0;\n\tlet y1 = 0;\n\tcn = Math.floor(cn / 2);\n\twhile (cn--) {\n\t\ty1 = ar * y0 - y1 + c[--k];\n\t\ty0 = ar * y1 - y0 + c[--k];\n\t}\n\treturn 2 * sinx * cosx * y0;\n}\n\n// Solves k⁴+2k³−(x²+y²−1)k²−2y²k−y²=0 for the positive root k.\n// Used to estimate the initial azimuth for near-antipodal pairs (§8).\nfunction astroid(x: number, y: number): number {\n\tconst p = squared(x);\n\tconst q = squared(y);\n\tconst r = (p + q - 1) / 6;\n\t// Oblate ellipsoid (f > 0, WGS84) — q === 0 && r <= 0 is unreachable because\n\t// astroid is only called from the near-antipodal branch, where either y < 0\n\t// (q > 0) or |x| > 1 (r > 0). Restore the guard if f is ever made a parameter.\n\t// if (!(q === 0 && r <= 0)) {\n\tconst S = (p * q) / 4;\n\tconst r2 = squared(r);\n\tconst r3 = r * r2;\n\tconst disc = S * (S + 2 * r3);\n\tlet u = r;\n\tif (disc >= 0) {\n\t\tlet T3 = S + r3;\n\t\t// Oblate ellipsoid (f > 0, WGS84) — S > 0 always at the call site (x < 0 and\n\t\t// |y| > TOL1), so T3 < 0 and T = 0 both force disc < 0, contradicting the\n\t\t// enclosing disc ≥ 0 branch. Restore both guards if astroid is ever called\n\t\t// with S = 0 (i.e. x = 0 or y = 0).\n\t\t// T3 += T3 < 0 ? -Math.sqrt(disc) : Math.sqrt(disc);\n\t\tT3 += Math.sqrt(disc);\n\t\tconst T = Math.cbrt(T3);\n\t\t// u += T + (T !== 0 ? r2 / T : 0);\n\t\tu += T + r2 / T;\n\t} else {\n\t\tconst ang = Math.atan2(Math.sqrt(-disc), -(S + r3));\n\t\tu += 2 * r * Math.cos(ang / 3);\n\t}\n\tconst v = Math.sqrt(squared(u) + q);\n\tconst uv = u < 0 ? q / (v - u) : u + v;\n\tconst w = (uv - q) / (2 * v);\n\treturn uv / (Math.sqrt(uv + squared(w)) + w);\n\t// }\n\t// return 0;\n}\n\n// ── Series evaluators (Karney 2013, §7) ───────────────────────────────────\n// A₁(ε) − 1: scale factor for arc-length integral I₁ (eq. 17)\nfunction A1m1f(eps: number): number {\n\tconst p = Math.floor(ORDER / 2);\n\tconst t = polyval(p, A1M1_COEFF, 0, squared(eps)) / A1M1_COEFF[p + 1];\n\treturn (t + eps) / (1 - eps);\n}\n// C₁[l](ε): Fourier coefficients of B₁ correction (eq. 18)\nfunction C1f(eps: number, c: Array<number>): void {\n\tconst eps2 = squared(eps);\n\tlet d = eps;\n\tlet o = 0;\n\tfor (let l = 1; l <= ORDER; l++) {\n\t\tconst p = Math.floor((ORDER - l) / 2);\n\t\tc[l] = (d * polyval(p, C1_COEFF, o, eps2)) / C1_COEFF[o + p + 1];\n\t\to += p + 2;\n\t\td *= eps;\n\t}\n}\n// A₂(ε) − 1: scale factor for reduced-length integral I₂\nfunction A2m1f(eps: number): number {\n\tconst p = Math.floor(ORDER / 2);\n\tconst t = polyval(p, A2M1_COEFF, 0, squared(eps)) / A2M1_COEFF[p + 1];\n\treturn (t - eps) / (1 + eps);\n}\n// C₂[l](ε): Fourier coefficients of B₂ correction\nfunction C2f(eps: number, c: Array<number>): void {\n\tconst eps2 = squared(eps);\n\tlet d = eps;\n\tlet o = 0;\n\tfor (let l = 1; l <= ORDER; l++) {\n\t\tconst p = Math.floor((ORDER - l) / 2);\n\t\tc[l] = (d * polyval(p, C2_COEFF, o, eps2)) / C2_COEFF[o + p + 1];\n\t\to += p + 2;\n\t\td *= eps;\n\t}\n}\n\n// Precompute A₃ and C₃ series as polynomials in ε, evaluated at WGS84 n (§9)\nfunction buildA3x(): Array<number> {\n\tconst ax: Array<number> = new Array(ORDER);\n\tlet o = 0;\n\tlet k = 0;\n\tfor (let j = ORDER - 1; j >= 0; j--) {\n\t\tconst p = Math.min(ORDER - j - 1, j);\n\t\tax[k++] = polyval(p, A3_COEFF, o, n) / A3_COEFF[o + p + 1];\n\t\to += p + 2;\n\t}\n\treturn ax;\n}\nfunction buildC3x(): Array<number> {\n\tconst cx: Array<number> = [];\n\tlet o = 0;\n\tfor (let l = 1; l < ORDER; l++) {\n\t\tfor (let j = ORDER - 1; j >= l; j--) {\n\t\t\tconst p = Math.min(ORDER - j - 1, j);\n\t\t\tcx.push(polyval(p, C3_COEFF, o, n) / C3_COEFF[o + p + 1]);\n\t\t\to += p + 2;\n\t\t}\n\t}\n\treturn cx;\n}\nconst A3x = buildA3x();\nconst C3x = buildC3x();\n\n// A₃(ε): scale factor for longitude integral I₃ (eq. 24)\nfunction A3f(eps: number): number {\n\treturn polyval(ORDER - 1, A3x, 0, eps);\n}\n// C₃[l](ε): Fourier coefficients of B₃ correction (eq. 25)\nfunction C3f(eps: number, c: Array<number>): void {\n\tlet mult = 1;\n\tlet o = 0;\n\tfor (let l = 1; l < ORDER; l++) {\n\t\tconst p = ORDER - l - 1;\n\t\tmult *= eps;\n\t\tc[l] = mult * polyval(p, C3x, o, eps);\n\t\to += p + 1;\n\t}\n}\n\n// ── Arc-length integrals (Karney 2013, §7) ────────────────────────────────\n// Returns s₁₂/b (geodesic distance scaled by b) and m₁₂/b (reduced length / b)\nfunction geodesicLengths(\n\teps: number,\n\tsig12: number,\n\tssig1: number,\n\tcsig1: number,\n\tdn1: number,\n\tssig2: number,\n\tcsig2: number,\n\tdn2: number,\n\tC1a: Array<number>,\n\tC2a: Array<number>,\n): { s12b: number; m12b: number } {\n\tC1f(eps, C1a);\n\tC2f(eps, C2a);\n\tconst a1 = A1m1f(eps);\n\tconst a2 = A2m1f(eps);\n\tconst m0x = a1 - a2;\n\tconst A1 = 1 + a1;\n\tconst A2 = 1 + a2;\n\tconst B1 =\n\t\tsinCosSeries(ssig2, csig2, C1a) - sinCosSeries(ssig1, csig1, C1a);\n\tconst B2 =\n\t\tsinCosSeries(ssig2, csig2, C2a) - sinCosSeries(ssig1, csig1, C2a);\n\tconst J12 = m0x * sig12 + (A1 * B1 - A2 * B2);\n\treturn {\n\t\ts12b: A1 * (sig12 + B1),\n\t\tm12b:\n\t\t\tdn2 * (csig1 * ssig2) - dn1 * (ssig1 * csig2) - csig1 * csig2 * J12,\n\t};\n}\n\n// ── Λ₁₂: longitude difference on the ellipsoid (Karney 2013, §8) ──────────\nfunction Lambda12(\n\tsbet1: number,\n\tcbet1: number,\n\tdn1: number,\n\tsbet2: number,\n\tcbet2: number,\n\tdn2: number,\n\tsalp1: number,\n\tcalp1: number,\n\tslam12: number,\n\tclam12: number,\n\t_diffp: boolean,\n\tC1a: Array<number>,\n\tC2a: Array<number>,\n\tC3a: Array<number>,\n): {\n\tlam12: number;\n\tdlam12: number;\n\tsalp2: number;\n\tcalp2: number;\n\tsig12: number;\n\tssig1: number;\n\tcsig1: number;\n\tssig2: number;\n\tcsig2: number;\n\teps: number;\n} {\n\t// Oblate ellipsoid (f > 0, WGS84) — sbet1 = 0 occurs for equatorial lat1 but\n\t// calp1 is never simultaneously 0 in practice: the initial azimuth is always\n\t// non-zero for all reachable equatorial near-antipodal cases. Restore the guard\n\t// if the algorithm is ever extended to cases where calp1 can reach exactly 0\n\t// with sbet1 = 0 (breaks the degeneracy of the equatorial line, Karney §8).\n\t// if (sbet1 === 0 && calp1 === 0) calp1 = -TINY;\n\tconst salp0 = salp1 * cbet1;\n\tconst calp0 = hypot(calp1, salp1 * sbet1);\n\n\tlet ssig1 = sbet1;\n\tconst somg1 = salp0 * sbet1;\n\tlet csig1 = calp1 * cbet1;\n\tconst comg1 = csig1;\n\tlet t = hypot(ssig1, csig1);\n\tssig1 /= t;\n\tcsig1 /= t;\n\n\tconst salp2 = cbet2 !== cbet1 ? salp0 / cbet2 : salp1;\n\tconst calp2 =\n\t\tcbet2 !== cbet1 || Math.abs(sbet2) !== -sbet1\n\t\t\t? Math.sqrt(\n\t\t\t\t\tsquared(calp1 * cbet1) +\n\t\t\t\t\t\t(cbet1 < -sbet1\n\t\t\t\t\t\t\t? (cbet2 - cbet1) * (cbet1 + cbet2)\n\t\t\t\t\t\t\t: (sbet1 - sbet2) * (sbet1 + sbet2)),\n\t\t\t\t) / cbet2\n\t\t\t: Math.abs(calp1);\n\n\tlet ssig2 = sbet2;\n\tconst somg2 = salp0 * sbet2;\n\tlet csig2 = calp2 * cbet2;\n\tconst comg2 = csig2;\n\tt = hypot(ssig2, csig2);\n\tssig2 /= t;\n\tcsig2 /= t;\n\n\tconst sig12 = Math.atan2(\n\t\tMath.max(0, csig1 * ssig2 - ssig1 * csig2),\n\t\tcsig1 * csig2 + ssig1 * ssig2,\n\t);\n\n\tconst somg12 = Math.max(0, comg1 * somg2 - somg1 * comg2);\n\tconst comg12 = comg1 * comg2 + somg1 * somg2;\n\tconst eta = Math.atan2(\n\t\tsomg12 * clam12 - comg12 * slam12,\n\t\tcomg12 * clam12 + somg12 * slam12,\n\t);\n\n\tconst k2 = squared(calp0) * ep2;\n\tconst eps = k2 / (2 * (1 + Math.sqrt(1 + k2)) + k2);\n\tC3f(eps, C3a);\n\tconst B312 =\n\t\tsinCosSeries(ssig2, csig2, C3a) - sinCosSeries(ssig1, csig1, C3a);\n\tconst domg12 = -f * A3f(eps) * salp0 * (sig12 + B312);\n\tconst lam12 = eta + domg12;\n\n\t// Oblate ellipsoid (f > 0, WGS84) — diffp = (numit < MAXIT1) is always true\n\t// because Newton converges within MAXIT1 iterations. Restore the guard if the\n\t// algorithm is ever generalised to cases requiring more iterations.\n\t// let dlam12 = 0;\n\t// if (diffp) {\n\tlet dlam12: number;\n\tif (calp2 === 0) {\n\t\tdlam12 = (-2 * f1 * dn1) / sbet1;\n\t} else {\n\t\tconst nv = geodesicLengths(\n\t\t\teps,\n\t\t\tsig12,\n\t\t\tssig1,\n\t\t\tcsig1,\n\t\t\tdn1,\n\t\t\tssig2,\n\t\t\tcsig2,\n\t\t\tdn2,\n\t\t\tC1a,\n\t\t\tC2a,\n\t\t);\n\t\tdlam12 = (nv.m12b * f1) / (calp2 * cbet2);\n\t}\n\t// }\n\n\treturn {\n\t\tlam12,\n\t\tdlam12,\n\t\tsalp2,\n\t\tcalp2,\n\t\tsig12,\n\t\tssig1,\n\t\tcsig1,\n\t\tssig2,\n\t\tcsig2,\n\t\teps,\n\t};\n}\n\n// ── Initial azimuth estimate for Newton's method (Karney 2013, §8) ─────────\nfunction inverseStart(\n\tsbet1: number,\n\tcbet1: number,\n\t_dn1: number,\n\tsbet2: number,\n\tcbet2: number,\n\t_dn2: number,\n\tlam12: number,\n\tslam12: number,\n\tclam12: number,\n\t_C1a: Array<number>,\n\t_C2a: Array<number>,\n): {\n\tsig12: number;\n\tsalp1: number;\n\tcalp1: number;\n\tsalp2: number;\n\tcalp2: number;\n\tdnm: number;\n} {\n\tconst sbet12 = sbet2 * cbet1 - cbet2 * sbet1;\n\tconst cbet12 = cbet2 * cbet1 + sbet2 * sbet1;\n\tconst sbet12a = sbet2 * cbet1 + cbet2 * sbet1;\n\n\tconst shortline = cbet12 >= 0 && sbet12 < 0.5 && cbet2 * lam12 < 0.5;\n\tlet somg12: number;\n\tlet comg12: number;\n\tlet dnm = 1;\n\n\tif (shortline) {\n\t\tconst sbetm2 =\n\t\t\tsquared(sbet1 + sbet2) /\n\t\t\t(squared(sbet1 + sbet2) + squared(cbet1 + cbet2));\n\t\tdnm = Math.sqrt(1 + ep2 * sbetm2);\n\t\tconst omg12 = lam12 / (f1 * dnm);\n\t\tsomg12 = Math.sin(omg12);\n\t\tcomg12 = Math.cos(omg12);\n\t} else {\n\t\tsomg12 = slam12;\n\t\tcomg12 = clam12;\n\t}\n\n\tlet salp1 = cbet2 * somg12;\n\tlet calp1 =\n\t\tcomg12 >= 0\n\t\t\t? sbet12 + (cbet2 * sbet1 * squared(somg12)) / (1 + comg12)\n\t\t\t: sbet12a - (cbet2 * sbet1 * squared(somg12)) / (1 - comg12);\n\n\tconst ssig12 = hypot(salp1, calp1);\n\tconst csig12 = sbet1 * sbet2 + cbet1 * cbet2 * comg12;\n\n\tlet salp2 = 0;\n\tlet calp2 = 0;\n\tlet sig12 = -1;\n\n\tif (shortline && ssig12 < ETOL2) {\n\t\tsalp2 = cbet1 * somg12;\n\t\t// Oblate ellipsoid (f > 0, WGS84) — in the shortline ETOL2 branch omg12 is tiny,\n\t\t// so comg12 ≈ 1 > 0 always. The comg12 < 0 branch (: 1 - comg12) is unreachable.\n\t\t// Restore the full ternary if the ellipsoid or ETOL2 threshold is ever changed.\n\t\t// calp2 = sbet12 - cbet1 * sbet2 * (comg12 >= 0 ? squared(somg12) / (1 + comg12) : 1 - comg12);\n\t\tcalp2 = sbet12 - (cbet1 * sbet2 * squared(somg12)) / (1 + comg12);\n\t\tconst nt = hypot(salp2, calp2);\n\t\tsalp2 /= nt;\n\t\tcalp2 /= nt;\n\t\tsig12 = Math.atan2(ssig12, csig12);\n\t} else if (\n\t\tMath.abs(n) > 0.1 ||\n\t\tcsig12 >= 0 ||\n\t\tssig12 >= 6 * Math.abs(n) * Math.PI * squared(cbet1)\n\t) {\n\t\t// spherical approximation is good enough\n\t} else {\n\t\tconst lam12x = Math.atan2(-slam12, -clam12);\n\n\t\t// Prolate ellipsoid (f < 0) — unreachable while f is a WGS84 constant\n\t\t// (f = 1/EARTH_FLATTENING ≈ +1/298.257 > 0). Restore and test this\n\t\t// block if f is ever made a parameter or the ellipsoid is generalised.\n\t\t// Restoring the prolate else branch would require changing these to let.\n\t\t// if (f >= 0) {\n\t\tconst k2 = squared(sbet1) * ep2;\n\t\tconst eps = k2 / (2 * (1 + Math.sqrt(1 + k2)) + k2);\n\t\tconst lamscale = f * cbet1 * A3f(eps) * Math.PI;\n\t\tconst betscale = lamscale * cbet1;\n\t\tconst x = lam12x / lamscale;\n\t\tconst y = sbet12a / betscale;\n\t\t// } else {\n\t\t//\tconst cbet12a = cbet2 * cbet1 - sbet2 * sbet1;\n\t\t//\tconst bet12a = Math.atan2(sbet12a, cbet12a);\n\t\t//\tconst nv = geodesicLengths(n, Math.PI + bet12a, sbet1, -cbet1,\n\t\t//\t _dn1, sbet2, cbet2, _dn2, _C1a, _C2a);\n\t\t//\tconst m12b = nv.m12b;\n\t\t//\tconst m0 = A1m1f(n) - A2m1f(n);\n\t\t//\tx = -1 + m12b / (cbet1 * cbet2 * m0 * Math.PI);\n\t\t//\tbetscale = x < -0.01 ? sbet12a / x : -f * squared(cbet1) * Math.PI;\n\t\t//\tlamscale = betscale / cbet1;\n\t\t//\ty = lam12 / lamscale;\n\t\t// }\n\n\t\tif (y > -TOL1 && x > -1 - XTHRESH) {\n\t\t\t// Prolate ellipsoid (f < 0) — unreachable for WGS84; see note above.\n\t\t\t// if (f < 0) {\n\t\t\t//\tcalp1 = Math.max(x > -TOL1 ? 0 : -1, x);\n\t\t\t//\tsalp1 = Math.sqrt(1 - squared(calp1));\n\t\t\t// } else {\n\t\t\tsalp1 = Math.min(1, -x);\n\t\t\tcalp1 = -Math.sqrt(1 - squared(salp1));\n\t\t\t// }\n\t\t} else {\n\t\t\tconst k = astroid(x, y);\n\t\t\t// Prolate ellipsoid (f < 0) uses (-y * (1 + k)) / k — unreachable for WGS84.\n\t\t\tconst omg12a = lamscale * ((-x * k) / (1 + k));\n\t\t\tsomg12 = Math.sin(omg12a);\n\t\t\tcomg12 = -Math.cos(omg12a);\n\t\t\tsalp1 = cbet2 * somg12;\n\t\t\tcalp1 = sbet12a - (cbet2 * sbet1 * squared(somg12)) / (1 - comg12);\n\t\t}\n\t}\n\n\tif (!(salp1 <= 0)) {\n\t\tconst nt = hypot(salp1, calp1);\n\t\tsalp1 /= nt;\n\t\tcalp1 /= nt;\n\t} else {\n\t\tsalp1 = 1;\n\t\tcalp1 = 0;\n\t}\n\n\treturn { sig12, salp1, calp1, salp2, calp2, dnm };\n}\n\n// ── Inverse geodesic distance (Karney 2013, §8) ───────────────────────────\nfunction inverseDistance(\n\tlat1: number,\n\tlon1: number,\n\tlat2: number,\n\tlon2: number,\n): number {\n\tlet φ1 = Math.max(-90, Math.min(90, lat1));\n\tlet φ2 = Math.max(-90, Math.min(90, lat2));\n\n\t// Normalise longitude difference to [0, 180]\n\tlet lon12 = angNormalize(angNormalize(lon2) - angNormalize(lon1));\n\tconst lonsign = lon12 >= 0 ? 1 : -1;\n\tlon12 = lonsign * lon12;\n\tconst slam12 = lon12 === 180 ? 0 : Math.sin(lon12 * D2R);\n\tconst clam12 = Math.cos(lon12 * D2R);\n\n\t// Canonical form: |lat1| ≥ |lat2|, lat1 ≤ 0\n\tconst swapp = Math.abs(φ1) >= Math.abs(φ2) ? 1 : -1;\n\tif (swapp < 0) [φ2, φ1] = [φ1, φ2];\n\tconst latsign = φ1 <= 0 ? 1 : -1;\n\tφ1 *= latsign;\n\tφ2 *= latsign;\n\n\t// Parametric latitudes: tan β = (1−f) tan φ\n\tlet sbet1 = f1 * Math.sin(φ1 * D2R);\n\tlet cbet1 = Math.cos(φ1 * D2R);\n\tlet t = hypot(sbet1, cbet1);\n\tsbet1 /= t;\n\tcbet1 /= t;\n\tcbet1 = Math.max(TINY, cbet1);\n\n\tlet sbet2 = f1 * Math.sin(φ2 * D2R);\n\tlet cbet2 = Math.cos(φ2 * D2R);\n\tt = hypot(sbet2, cbet2);\n\tsbet2 /= t;\n\tcbet2 /= t;\n\tcbet2 = Math.max(TINY, cbet2);\n\n\t// Enforce exact symmetry for antipodal/coincident pole cases\n\tif (cbet1 < -sbet1) {\n\t\tif (cbet2 === cbet1) sbet2 = copysign(sbet1, sbet2);\n\t} else {\n\t\tif (Math.abs(sbet2) === -sbet1) cbet2 = cbet1;\n\t}\n\n\tconst dn1 = Math.sqrt(1 + ep2 * squared(sbet1));\n\tconst dn2 = Math.sqrt(1 + ep2 * squared(sbet2));\n\n\tconst lam12 = lon12 * D2R;\n\tconst C1a = new Array(ORDER + 1);\n\tconst C2a = new Array(ORDER + 1);\n\tconst C3a = new Array(ORDER);\n\n\tlet s12b: number;\n\tlet calp1: number;\n\tlet salp1: number;\n\tlet calp2: number;\n\tlet ssig1: number;\n\tlet csig1: number;\n\tlet ssig2: number;\n\tlet csig2: number;\n\tlet eps: number;\n\n\tconst meridian = φ1 === -90 || slam12 === 0;\n\n\tif (meridian) {\n\t\tcalp1 = clam12;\n\t\tsalp1 = slam12;\n\t\tcalp2 = 1;\n\t\tssig1 = sbet1;\n\t\tcsig1 = calp1 * cbet1;\n\t\tssig2 = sbet2;\n\t\tcsig2 = calp2 * cbet2;\n\t\tconst sig12m = Math.atan2(\n\t\t\tMath.max(0, csig1 * ssig2 - ssig1 * csig2),\n\t\t\tcsig1 * csig2 + ssig1 * ssig2,\n\t\t);\n\t\t// For a meridional geodesic calp₀ = 1, so ε → n (third flattening).\n\t\t// GeographicLib evaluates geodesicLengths at n directly for this branch.\n\t\teps = n;\n\t\tconst nv = geodesicLengths(\n\t\t\teps,\n\t\t\tsig12m,\n\t\t\tssig1,\n\t\t\tcsig1,\n\t\t\tdn1,\n\t\t\tssig2,\n\t\t\tcsig2,\n\t\t\tdn2,\n\t\t\tC1a,\n\t\t\tC2a,\n\t\t);\n\t\ts12b = nv.s12b;\n\t\t// Oblate ellipsoid (f > 0, WGS84) — the second clause is unreachable: TINY === TOL0,\n\t\t// so sig12m < TOL0 ⊆ sig12m < 3*TINY, meaning the first clause always fires first.\n\t\t// Restore the second clause if TINY and TOL0 are ever decoupled.\n\t\t// if (sig12m < 3 * TINY || (sig12m < TOL0 && (s12b < 0 || nv.m12b < 0))) {\n\t\tif (sig12m < 3 * TINY) {\n\t\t\ts12b = 0;\n\t\t}\n\t\treturn b * s12b;\n\t}\n\n\t// Equatorial geodesic — only valid when the supplementary longitude\n\t// (180° − lon12) ≥ f·180°; near-antipodal equatorial pairs fall through\n\t// to Newton's method, which finds the shorter off-equator geodesic.\n\tif (sbet1 === 0 && (f <= 0 || 180 - lon12 >= f * 180)) {\n\t\treturn a * lam12;\n\t}\n\n\t// General case: Newton's method on Λ₁₂(α₁) = lam12 (§8)\n\tconst ns = inverseStart(\n\t\tsbet1,\n\t\tcbet1,\n\t\tdn1,\n\t\tsbet2,\n\t\tcbet2,\n\t\tdn2,\n\t\tlam12,\n\t\tslam12,\n\t\tclam12,\n\t\tC1a,\n\t\tC2a,\n\t);\n\tlet sig12 = ns.sig12;\n\tsalp1 = ns.salp1;\n\tcalp1 = ns.calp1;\n\n\tif (sig12 >= 0) {\n\t\tcalp2 = ns.calp2;\n\t\ts12b = sig12 * b * ns.dnm;\n\t\treturn s12b;\n\t}\n\n\tcalp2 = 0;\n\tssig1 = 0;\n\tcsig1 = 0;\n\tssig2 = 0;\n\tcsig2 = 0;\n\teps = 0;\n\n\tlet salp1a = TINY;\n\tlet calp1a = 1;\n\tlet salp1b = TINY;\n\tlet calp1b = -1;\n\tlet tripn = false;\n\tlet tripb = false;\n\n\tfor (let numit = 0; ; ++numit) {\n\t\tconst lv = Lambda12(\n\t\t\tsbet1,\n\t\t\tcbet1,\n\t\t\tdn1,\n\t\t\tsbet2,\n\t\t\tcbet2,\n\t\t\tdn2,\n\t\t\tsalp1,\n\t\t\tcalp1,\n\t\t\tslam12,\n\t\t\tclam12,\n\t\t\tnumit < MAXIT1,\n\t\t\tC1a,\n\t\t\tC2a,\n\t\t\tC3a,\n\t\t);\n\t\tconst v = lv.lam12;\n\t\tcalp2 = lv.calp2;\n\t\tsig12 = lv.sig12;\n\t\tssig1 = lv.ssig1;\n\t\tcsig1 = lv.csig1;\n\t\tssig2 = lv.ssig2;\n\t\tcsig2 = lv.csig2;\n\t\teps = lv.eps;\n\t\tconst dv = lv.dlam12;\n\n\t\tif (\n\t\t\ttripb ||\n\t\t\t!(Math.abs(v) >= (tripn ? 8 : 1) * TOL0) ||\n\t\t\tnumit === MAXIT2\n\t\t)\n\t\t\tbreak;\n\n\t\t// Oblate ellipsoid (f > 0, WGS84) — Newton always converges within MAXIT1\n\t\t// iterations, so the secondary ratio guards and the MAXIT1 guards are\n\t\t// unreachable. The v === 0 path is also unreachable: the break condition above\n\t\t// fires whenever |v| < TOL0, so v is never exactly 0 here. Restore all of\n\t\t// them if the algorithm is ever generalised.\n\t\t// if (v > 0 && (numit < MAXIT1 || calp1 / salp1 > calp1b / salp1b)) {\n\t\t// Split into two independent ifs (rather than if/else-if) so the v === 0\n\t\t// case — unreachable because the break above fires whenever |v| < TOL0 —\n\t\t// does not produce a structural else-branch that the coverage tool tracks.\n\t\tif (v > 0) {\n\t\t\tsalp1b = salp1;\n\t\t\tcalp1b = calp1;\n\t\t}\n\t\t// } else if (v < 0 && (numit < MAXIT1 || calp1 / salp1 < calp1a / salp1a)) {\n\t\tif (v < 0) {\n\t\t\tsalp1a = salp1;\n\t\t\tcalp1a = calp1;\n\t\t}\n\n\t\t// Oblate ellipsoid (f > 0, WGS84) — Newton converges within MAXIT1 iterations,\n\t\t// dv (= dlam12) is always positive, and |dalp1| is always < π for WGS84.\n\t\t// Restore the guards below if the algorithm is ever generalised (those paths\n\t\t// fall through to bisection but are never reached for WGS84).\n\t\t// if (numit < MAXIT1 && dv > 0) {\n\t\t// if (Math.abs(dalp1) < Math.PI) {\n\t\t{\n\t\t\tconst dalp1 = -v / dv;\n\t\t\tconst sdalp1 = Math.sin(dalp1);\n\t\t\tconst cdalp1 = Math.cos(dalp1);\n\t\t\tconst nsalp1 = salp1 * cdalp1 + calp1 * sdalp1;\n\t\t\tif (nsalp1 > 0) {\n\t\t\t\tcalp1 = calp1 * cdalp1 - salp1 * sdalp1;\n\t\t\t\tsalp1 = nsalp1;\n\t\t\t\tt = hypot(salp1, calp1);\n\t\t\t\tsalp1 /= t;\n\t\t\t\tcalp1 /= t;\n\t\t\t\ttripn = Math.abs(v) <= 16 * TOL0;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\t// }\n\t\t\t// }\n\t\t}\n\t\tsalp1 = (salp1a + salp1b) / 2;\n\t\tcalp1 = (calp1a + calp1b) / 2;\n\t\tt = hypot(salp1, calp1);\n\t\tsalp1 /= t;\n\t\tcalp1 /= t;\n\t\ttripn = false;\n\t\ttripb =\n\t\t\tMath.abs(salp1a - salp1) + (calp1a - calp1) < TOLB ||\n\t\t\tMath.abs(salp1 - salp1b) + (calp1 - calp1b) < TOLB;\n\t}\n\n\tconst nv = geodesicLengths(\n\t\teps,\n\t\tsig12,\n\t\tssig1,\n\t\tcsig1,\n\t\tdn1,\n\t\tssig2,\n\t\tcsig2,\n\t\tdn2,\n\t\tC1a,\n\t\tC2a,\n\t);\n\treturn b * nv.s12b;\n}\n\n// ── Public interface ───────────────────────────────────────────────────────\nexport function karney([lon1, lat1]: Position, [lon2, lat2]: Position): number {\n\treturn inverseDistance(lat1, lon1, lat2, lon2);\n}\n","import {\n\tEARTH_FLATTENING,\n\tEARTH_RADIUS,\n\tEARTH_RADIUS_MAJOR,\n\tEARTH_RADIUS_MINOR,\n} from '../Constants';\nimport type { Point } from '../GeoJSON/Geometry/Point';\nimport { createBoxFromCoordinates, isWithinBox } from './Box';\nimport { karney } from './Geodesic';\nimport { squared } from './Numeric';\n\nconst D2R = Math.PI / 180;\nconst π = Math.PI;\n\nfunction constrain(value: number, min: number, max: number): number {\n\treturn Math.max(Math.min(value, max), min);\n}\n\nfunction rad(n: number): number {\n\treturn n * D2R;\n}\n\nconst EARTH_RADIUS_MAJOR_SQUARED = squared(EARTH_RADIUS_MAJOR);\nconst EARTH_RADIUS_MINOR_SQUARED = squared(EARTH_RADIUS_MINOR);\nconst EARTH_RADIUS_FACTOR =\n\t(EARTH_RADIUS_MAJOR_SQUARED - EARTH_RADIUS_MINOR_SQUARED) /\n\tEARTH_RADIUS_MINOR_SQUARED;\nconst EARTH_INVERSE_FLATTENING = 1 / EARTH_FLATTENING;\n\nexport function cartesian(\n\t[λa, φa]: Point['coordinates'],\n\t[λb, φb]: Point['coordinates'],\n): number {\n\treturn EARTH_RADIUS * rad(Math.sqrt(squared(λb - λa) + squared(φb - φa)));\n}\n\nexport function haversine(\n\t[λa, φa]: Point['coordinates'],\n\t[λb, φb]: Point['coordinates'],\n): number {\n\t//https://www.movable-type.co.uk/scripts/latlong.html\n\tconst Δ =\n\t\tsquared(Math.sin(rad(φb - φa) / 2)) +\n\t\tMath.cos(rad(φa)) *\n\t\t\tMath.cos(rad(φb)) *\n\t\t\tsquared(Math.sin(rad(λb - λa) / 2));\n\n\treturn EARTH_RADIUS * Math.atan2(Math.sqrt(Δ), Math.sqrt(1 - Δ)) * 2;\n}\n\nexport function vincenty(\n\ta: Point['coordinates'],\n\tb: Point['coordinates'],\n): number {\n\t//https://www.movable-type.co.uk/scripts/latlong-vincenty.html\n\tconst [[λ1, φ1], [λ2, φ2]] = [a, b].map((p) => (<Array<number>>p).map(rad));\n\tconst L = λ2 - λ1; // L = difference in longitude, U = reduced latitude, defined by tan U = (1-f)·tanφ.\n\tconst tanU1 = (1 - EARTH_INVERSE_FLATTENING) * Math.tan(φ1),\n\t\tcosU1 = 1 / Math.sqrt(1 + tanU1 * tanU1),\n\t\tsinU1 = tanU1 * cosU1;\n\tconst tanU2 = (1 - EARTH_INVERSE_FLATTENING) * Math.tan(φ2),\n\t\tcosU2 = 1 / Math.sqrt(1 + tanU2 * tanU2),\n\t\tsinU2 = tanU2 * cosU2;\n\n\tconst antipodal = Math.abs(L) > π / 2 || Math.abs(φ2 - φ1) > π / 2;\n\n\tlet λ = L;\n\tlet sinλ = null;\n\tlet cosλ = null; // λ = difference in longitude on an auxiliary sphere\n\tlet σ = antipodal ? π : 0;\n\tlet sinσ = 0;\n\tlet cosσ = antipodal ? -1 : 1;\n\tlet sinSqσ = null; // σ = angular distance P₁ P₂ on the sphere\n\tlet cos2σₘ = 1; // σₘ = angular distance on the sphere from the equator to the midpoint of the line\n\tlet cosSqα = 1; // α = azimuth of the geodesic at the equator\n\tlet λʹ = null;\n\tlet prevΔλ = Infinity;\n\tlet iterations = 0;\n\n\tdo {\n\t\tsinλ = Math.sin(λ);\n\t\tcosλ = Math.cos(λ);\n\t\tsinSqσ =\n\t\t\t(cosU2 * sinλ) ** 2 + (cosU1 * sinU2 - sinU1 * cosU2 * cosλ) ** 2;\n\t\tif (Math.abs(sinSqσ) < 1e-24) break; // co-incident/antipodal points (σ < ≈0.006mm)\n\t\tsinσ = Math.sqrt(sinSqσ);\n\t\tcosσ = sinU1 * sinU2 + cosU1 * cosU2 * cosλ;\n\t\tσ = Math.atan2(sinσ, cosσ);\n\t\tconst sinα = (cosU1 * cosU2 * sinλ) / sinσ;\n\t\tcosSqα = 1 - sinα * sinα;\n\t\tcos2σₘ = cosSqα !== 0 ? cosσ - (2 * sinU1 * sinU2) / cosSqα : 0; // on equatorial line cos²α = 0 (§6)\n\t\tconst C =\n\t\t\t(EARTH_INVERSE_FLATTENING / 16) *\n\t\t\tcosSqα *\n\t\t\t(4 + EARTH_INVERSE_FLATTENING * (4 - 3 * cosSqα));\n\t\tλʹ = λ;\n\t\tλ =\n\t\t\tL +\n\t\t\t(1 - C) *\n\t\t\t\tEARTH_INVERSE_FLATTENING *\n\t\t\t\tsinα *\n\t\t\t\t(σ +\n\t\t\t\t\tC *\n\t\t\t\t\t\tsinσ *\n\t\t\t\t\t\t(cos2σₘ + C * cosσ * (-1 + 2 * cos2σₘ * cos2σₘ)));\n\t\tconst Δλ = Math.abs(λ - λʹ);\n\t\t// 2-cycle detection (floating-point fixed point) or hard iteration cap\n\t\tif ((Δλ !== 0 && Δλ === prevΔλ) || ++iterations > 1000)\n\t\t\tthrow new EvalError('Vincenty formula failed to converge');\n\t\tprevΔλ = Δλ;\n\t} while (Math.abs(λ - λʹ) > 1e-12); // TV: 'iterate until negligible change in λ' (≈0.006mm)\n\n\tconst uSq = cosSqα * EARTH_RADIUS_FACTOR;\n\tconst A =\n\t\t1 + (uSq / 16384) * (4096 + uSq * (-768 + uSq * (320 - 175 * uSq)));\n\tconst B = (uSq / 1024) * (256 + uSq * (-128 + uSq * (74 - 47 * uSq)));\n\tconst Δσ =\n\t\tB *\n\t\tsinσ *\n\t\t(cos2σₘ +\n\t\t\t(B / 4) *\n\t\t\t\t(cosσ * (-1 + 2 * cos2σₘ * cos2σₘ) -\n\t\t\t\t\t(B / 6) *\n\t\t\t\t\t\tcos2σₘ *\n\t\t\t\t\t\t(-3 + 4 * sinσ * sinσ) *\n\t\t\t\t\t\t(-3 + 4 * cos2σₘ * cos2σₘ)));\n\n\treturn EARTH_RADIUS_MINOR * A * (σ - Δσ);\n}\n\nconst PointToPoint: {\n\t[key: string]: (a: Point['coordinates'], b: Point['coordinates']) => number;\n} = {\n\tcartesian,\n\thaversine,\n\tvincenty,\n\tkarney,\n};\n\nexport type PointToPointCalculation =\n\t| 'cartesian'\n\t| 'haversine'\n\t| 'vincenty'\n\t| 'karney'\n\t| ((a: Point['coordinates'], b: Point['coordinates']) => number);\n\nexport function getClosestPointOnLineByPoint(\n\tpoint: Point['coordinates'],\n\tline: [Point['coordinates'], Point['coordinates']],\n): Point['coordinates'] {\n\tconst [[px, py], [ax, ay], [bx, by]] = [point, ...line];\n\tconst [abx, aby] = [bx - ax, by - ay];\n\tconst [apx, apy] = [px - ax, py - ay];\n\tconst t = constrain(\n\t\t(apx * abx + apy * aby) / (abx * abx + aby * aby),\n\t\t0,\n\t\t1,\n\t);\n\n\treturn t === 0 || t === 1 ? line[t] : [ax + abx * t, ay + aby * t];\n}\n\nexport function getDistanceOfPointToPoint(\n\ta: Point['coordinates'],\n\tb: Point['coordinates'],\n\tcalculation: PointToPointCalculation,\n): number {\n\tconst calc =\n\t\ttypeof calculation === 'function'\n\t\t\t? calculation\n\t\t\t: PointToPoint[calculation];\n\n\tif (typeof calc === 'function') {\n\t\treturn calc(a, b);\n\t}\n\n\tthrow new Error(`Not a PointToPoint calculation function ${calculation}`);\n}\n\nexport function getDistanceOfPointToLine(\n\tpoint: Point['coordinates'],\n\tline: [Point['coordinates'], Point['coordinates']],\n\tcalculation: PointToPointCalculation,\n): number {\n\treturn getDistanceOfPointToPoint(\n\t\tpoint,\n\t\tgetClosestPointOnLineByPoint(point, line),\n\t\tcalculation,\n\t);\n}\n\nexport function getDistanceOfLineToLine(\n\ta: [Point['coordinates'], Point['coordinates']],\n\tb: [Point['coordinates'], Point['coordinates']],\n\tcalculation: PointToPointCalculation,\n): number {\n\treturn isLinesCrossing(a, b)\n\t\t? 0\n\t\t: Math.min(\n\t\t\t\t...a.map((a) => getDistanceOfPointToLine(a, b, calculation)),\n\t\t\t\t...b.map((b) => getDistanceOfPointToLine(b, a, calculation)),\n\t\t\t);\n}\n\nexport function isLinesCrossing(\n\ta: [Point['coordinates'], Point['coordinates']],\n\tb: [Point['coordinates'], Point['coordinates']],\n): boolean {\n\tconst [[a1x, a1y], [a2x, a2y]] = a;\n\tconst [[b1x, b1y], [b2x, b2y]] = b;\n\tconst [s1x, s1y, s2x, s2y] = [a2x - a1x, a2y - a1y, b2x - b1x, b2y - b1y];\n\tconst s =\n\t\t(-s1y * (a1x - b1x) + s1x * (a1y - b1y)) / (-s2x * s1y + s1x * s2y);\n\tconst t =\n\t\t(s2x * (a1y - b1y) - s2y * (a1x - b1x)) / (-s2x * s1y + s1x * s2y);\n\n\treturn s >= 0 && s <= 1 && t >= 0 && t <= 1;\n}\n\nexport function isPointOnLine(\n\tpoint: Point['coordinates'],\n\tline: [Point['coordinates'], Point['coordinates']],\n\tthreshold: number = 1e-14,\n): boolean {\n\treturn getDistanceOfPointToLine(point, line, 'cartesian') < threshold;\n}\n\nexport function isPointInRing(\n\tp: Point['coordinates'],\n\tring: Array<Point['coordinates']>,\n): boolean {\n\tif (!isWithinBox(p, createBoxFromCoordinates(ring))) {\n\t\treturn false;\n\t}\n\n\tconst { length } = ring;\n\tconst odd = ring.reduce((odd, a, i) => {\n\t\tconst b = ring[(length + i - 1) % length];\n\n\t\treturn ((a[1] < p[1] && b[1] >= p[1]) ||\n\t\t\t(b[1] < p[1] && a[1] >= p[1])) &&\n\t\t\t(a[0] <= p[0] || b[0] <= p[0])\n\t\t\t? odd ^\n\t\t\t\t\tNumber(\n\t\t\t\t\t\ta[0] + ((p[1] - a[1]) / (b[1] - a[1])) * (b[0] - a[0]) <\n\t\t\t\t\t\t\tp[0],\n\t\t\t\t\t)\n\t\t\t: odd;\n\t}, 0);\n\n\treturn (\n\t\todd !== 0 ||\n\t\tring.slice(1).some((a, index) => isPointOnLine(p, [ring[index], a]))\n\t);\n}\n","import type { Point } from '../GeoJSON/Geometry/Point';\n\nexport function segments(\n\tline: Array<Point['coordinates']>,\n): Array<[Point['coordinates'], Point['coordinates']]> {\n\treturn line.slice(1).map((point, index) => [line[index], point]);\n}\n","import type { GeoJSON } from '../GeoJSON/GeoJSON';\nimport type { LineString } from '../GeoJSON/Geometry/LineString';\nimport type { Point } from '../GeoJSON/Geometry/Point';\nimport type { Polygon } from '../GeoJSON/Geometry/Polygon';\nimport { IterablePairIterator } from '../Iterator/IterablePair';\nimport { SimpleGeometryIterator } from '../Iterator/SimpleGeometry';\nimport {\n\tcartesian as cartesianCoords,\n\tgetDistanceOfLineToLine,\n\tgetDistanceOfPointToLine,\n\tgetDistanceOfPointToPoint,\n\thaversine as haversineCoords,\n\tisPointInRing,\n\ttype PointToPointCalculation,\n\tvincenty as vincentyCoords,\n} from './Calculate';\nimport { karney as karneyCoords } from './Geodesic';\nimport { segments } from './Segments';\n\nconst geometries = {\n\tPointPoint(\n\t\ta: Point['coordinates'],\n\t\tb: Point['coordinates'],\n\t\tcalculation: PointToPointCalculation,\n\t): number {\n\t\treturn getDistanceOfPointToPoint(a, b, calculation);\n\t},\n\tLineStringPoint(\n\t\ta: LineString['coordinates'],\n\t\tb: Point['coordinates'],\n\t\tcalculation: PointToPointCalculation,\n\t): number {\n\t\treturn Math.min(\n\t\t\t...segments(a).map((line) =>\n\t\t\t\tgetDistanceOfPointToLine(b, line, calculation),\n\t\t\t),\n\t\t);\n\t},\n\tLineStringLineString(\n\t\ta: LineString['coordinates'],\n\t\tb: LineString['coordinates'],\n\t\tcalculation: PointToPointCalculation,\n\t): number {\n\t\tconst sa = segments(a);\n\t\tconst sb = segments(b);\n\n\t\treturn sa.reduce(\n\t\t\t(carry, a) =>\n\t\t\t\tsb.reduce(\n\t\t\t\t\t(carry, b) =>\n\t\t\t\t\t\tcarry > 0\n\t\t\t\t\t\t\t? Math.min(\n\t\t\t\t\t\t\t\t\tcarry,\n\t\t\t\t\t\t\t\t\tgetDistanceOfLineToLine(a, b, calculation),\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t: carry,\n\t\t\t\t\tcarry,\n\t\t\t\t),\n\t\t\tInfinity,\n\t\t);\n\t},\n\tPolygonPoint(\n\t\t[exterior, ...interior]: Polygon['coordinates'],\n\t\tb: Point['coordinates'],\n\t\tcalculation: PointToPointCalculation,\n\t): number {\n\t\tif (isPointInRing(b, exterior)) {\n\t\t\tconst [excluded] = interior.filter((ring) =>\n\t\t\t\tisPointInRing(b, ring),\n\t\t\t);\n\n\t\t\treturn excluded\n\t\t\t\t? this.LineStringPoint(excluded, b, calculation)\n\t\t\t\t: 0;\n\t\t}\n\n\t\treturn this.LineStringPoint(exterior, b, calculation);\n\t},\n\tPolygonLineString(\n\t\ta: Polygon['coordinates'],\n\t\tb: LineString['coordinates'],\n\t\tcalculation: PointToPointCalculation,\n\t): number {\n\t\tconst [exterior, ...interior] = a;\n\t\tconst line = segments(b);\n\t\tconst ring = b.some((b) => isPointInRing(b, exterior))\n\t\t\t? interior.find((a) => b.every((b) => isPointInRing(b, a)))\n\t\t\t: exterior;\n\n\t\treturn ring\n\t\t\t? Math.min(\n\t\t\t\t\t...segments(ring).map((a) =>\n\t\t\t\t\t\tMath.min(\n\t\t\t\t\t\t\t...line.map((b) =>\n\t\t\t\t\t\t\t\tgetDistanceOfLineToLine(a, b, calculation),\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t),\n\t\t\t\t\t),\n\t\t\t\t)\n\t\t\t: 0;\n\t},\n\tPolygonPolygon(\n\t\ta: Polygon['coordinates'],\n\t\tb: Polygon['coordinates'],\n\t\tcalculation: PointToPointCalculation,\n\t): number {\n\t\treturn Math.min(\n\t\t\tthis.PolygonLineString(a, b[0], calculation),\n\t\t\tthis.PolygonLineString(b, a[0], calculation),\n\t\t);\n\t},\n};\n\nexport function cartesian(a: GeoJSON, b: GeoJSON): number {\n\treturn distance(a, b, cartesianCoords);\n}\n\nexport function haversine(a: GeoJSON, b: GeoJSON): number {\n\treturn distance(a, b, haversineCoords);\n}\n\nexport function vincenty(a: GeoJSON, b: GeoJSON): number {\n\treturn distance(a, b, vincentyCoords);\n}\n\nexport function karney(a: GeoJSON, b: GeoJSON): number {\n\treturn distance(a, b, karneyCoords);\n}\n\nexport function distance(\n\ta: GeoJSON,\n\tb: GeoJSON,\n\tcalculation: PointToPointCalculation = 'haversine',\n): number {\n\tconst lookup = <\n\t\tRecord<\n\t\t\tstring,\n\t\t\t(\n\t\t\t\ta: unknown,\n\t\t\t\tb: unknown,\n\t\t\t\tcalculation: PointToPointCalculation,\n\t\t\t) => number\n\t\t>\n\t>geometries;\n\treturn Math.min(\n\t\t...[\n\t\t\t...new IterablePairIterator(\n\t\t\t\tnew SimpleGeometryIterator(a),\n\t\t\t\tnew SimpleGeometryIterator(b),\n\t\t\t),\n\t\t].map(([a, b]) => {\n\t\t\treturn a.type + b.type in lookup\n\t\t\t\t? lookup[a.type + b.type](\n\t\t\t\t\t\ta.coordinates,\n\t\t\t\t\t\tb.coordinates,\n\t\t\t\t\t\tcalculation,\n\t\t\t\t\t)\n\t\t\t\t: b.type + a.type in lookup\n\t\t\t\t\t? lookup[b.type + a.type](\n\t\t\t\t\t\t\tb.coordinates,\n\t\t\t\t\t\t\ta.coordinates,\n\t\t\t\t\t\t\tcalculation,\n\t\t\t\t\t\t)\n\t\t\t\t\t: Infinity;\n\t\t}),\n\t);\n}\n","import type { GeoJSON } from '../GeoJSON/GeoJSON';\nimport type { LineString } from '../GeoJSON/Geometry/LineString';\nimport type { Point } from '../GeoJSON/Geometry/Point';\nimport type { Polygon } from '../GeoJSON/Geometry/Polygon';\nimport { IterablePairIterator } from '../Iterator/IterablePair';\nimport { SimpleGeometryIterator } from '../Iterator/SimpleGeometry';\nimport { isLinesCrossing, isPointInRing, isPointOnLine } from './Calculate';\nimport { segments } from './Segments';\n\nconst geometries = {\n\tPointPoint(a: Point['coordinates'], b: Point['coordinates']): boolean {\n\t\treturn (\n\t\t\ta.length >= 2 &&\n\t\t\tb.length >= 2 &&\n\t\t\ta.slice(0, 2).every((v, i) => v === b[i])\n\t\t);\n\t},\n\tLineStringPoint(\n\t\ta: LineString['coordinates'],\n\t\tb: Point['coordinates'],\n\t): boolean {\n\t\treturn (\n\t\t\ta.some((a) => this.PointPoint(a, b)) ||\n\t\t\tsegments(a).some((line) => isPointOnLine(b, line))\n\t\t);\n\t},\n\tLineStringLineString(\n\t\ta: LineString['coordinates'],\n\t\tb: LineString['coordinates'],\n\t): boolean {\n\t\tconst lines = segments(b);\n\n\t\treturn segments(a).some((a) =>\n\t\t\tlines.some((b) => isLinesCrossing(a, b)),\n\t\t);\n\t},\n\tPolygonPoint(\n\t\t[exterior, ...interior]: Polygon['coordinates'],\n\t\tb: Point['coordinates'],\n\t): boolean {\n\t\treturn (\n\t\t\t(this.LineStringPoint(exterior, b) || isPointInRing(b, exterior)) &&\n\t\t\t(!interior.length ||\n\t\t\t\tinterior.every((ring) => !isPointInRing(b, ring)))\n\t\t);\n\t},\n\tPolygonLineString(\n\t\ta: Polygon['coordinates'],\n\t\tb: LineString['coordinates'],\n\t): boolean {\n\t\treturn (\n\t\t\ta.some((ring) => this.LineStringLineString(ring, b)) ||\n\t\t\tb.some((point) => this.PolygonPoint(a, point))\n\t\t);\n\t},\n\tPolygonPolygon(\n\t\ta: Polygon['coordinates'],\n\t\tb: Polygon['coordinates'],\n\t): boolean {\n\t\treturn (\n\t\t\tb.some(\n\t\t\t\t(b1) =>\n\t\t\t\t\tthis.PolygonLineString(a, b1) ||\n\t\t\t\t\tb1.some((b2) => this.PolygonPoint(a, b2)),\n\t\t\t) ||\n\t\t\ta.some(\n\t\t\t\t(a1) =>\n\t\t\t\t\tthis.PolygonLineString(b, a1) ||\n\t\t\t\t\ta1.some((a2) => this.PolygonPoint(b, a2)),\n\t\t\t)\n\t\t);\n\t},\n};\n\nexport function intersect(a: GeoJSON, b: GeoJSON): boolean {\n\tconst lookup = <Record<string, (a: unknown, b: unknown) => boolean>>(\n\t\tgeometries\n\t);\n\tfor (const [itA, itB] of new IterablePairIterator(\n\t\tnew SimpleGeometryIterator(a),\n\t\tnew SimpleGeometryIterator(b),\n\t)) {\n\t\tif (\n\t\t\t(itA.type + itB.type in lookup &&\n\t\t\t\tlookup[itA.type + itB.type](\n\t\t\t\t\titA.coordinates,\n\t\t\t\t\titB.coordinates,\n\t\t\t\t)) ||\n\t\t\t(itB.type + itA.type in lookup &&\n\t\t\t\tlookup[itB.type + itA.type](itB.coordinates, itA.coordinates))\n\t\t) {\n\t\t\treturn true;\n\t\t}\n\t}\n\n\treturn false;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA,mBAAAA;AAAA,EAAA;AAAA,mBAAAC;AAAA,EAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;A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AA,IACL,KACA,IAAI,OAAO,IAAI,QAAQ,UACvB,OAAO,IAAI,OAAO,IAAI,IAAI,EAAE,IAAI,aAAa,IAAI,WAAW,GAC5D;AACD,aAAO;AAAA,IACR;AAAA,EACD;AAEA,SAAO;AACR;","names":["cartesian","haversine","karney","vincenty","types","value","a","b","n","positions","a","geometries","a","b","values","n","n","nv","D2R","n","a","b","odd","a","b","carry","cartesian","haversine","vincenty","karney","geometries","a","b","b2","a2"]}
|