From 98faffe0371952ca5470ca32dd33bc45ed58e41b Mon Sep 17 00:00:00 2001 From: John Gravois Date: Thu, 26 Mar 2026 19:46:18 -0700 Subject: [PATCH 1/2] chore: remove files compiled by TS from version control --- .gitignore | 2 + arc.js | 363 ----------------------------------- dist/arc.d.ts | 45 ----- dist/arc.d.ts.map | 1 - dist/arc.js | 111 ----------- dist/arc.js.map | 1 - dist/coord.d.ts | 45 ----- dist/coord.d.ts.map | 1 - dist/coord.js | 61 ------ dist/coord.js.map | 1 - dist/esm/arc.js | 107 ----------- dist/esm/arc.js.map | 1 - dist/esm/coord.js | 57 ------ dist/esm/coord.js.map | 1 - dist/esm/great-circle.js | 218 --------------------- dist/esm/great-circle.js.map | 1 - dist/esm/index.js | 7 - dist/esm/index.js.map | 1 - dist/esm/line-string.js | 17 -- dist/esm/line-string.js.map | 1 - dist/esm/types.js | 2 - dist/esm/types.js.map | 1 - dist/esm/utils.js | 36 ---- dist/esm/utils.js.map | 1 - dist/great-circle.d.ts | 53 ----- dist/great-circle.d.ts.map | 1 - dist/great-circle.js | 222 --------------------- dist/great-circle.js.map | 1 - dist/index.d.ts | 7 - dist/index.d.ts.map | 1 - dist/index.js | 17 -- dist/index.js.map | 1 - dist/line-string.d.ts | 15 -- dist/line-string.d.ts.map | 1 - dist/line-string.js | 21 -- dist/line-string.js.map | 1 - dist/types.d.ts | 30 --- dist/types.d.ts.map | 1 - dist/types.js | 3 - dist/types.js.map | 1 - dist/utils.d.ts | 24 --- dist/utils.d.ts.map | 1 - dist/utils.js | 40 ---- dist/utils.js.map | 1 - 44 files changed, 2 insertions(+), 1522 deletions(-) delete mode 100644 arc.js delete mode 100644 dist/arc.d.ts delete mode 100644 dist/arc.d.ts.map delete mode 100644 dist/arc.js delete mode 100644 dist/arc.js.map delete mode 100644 dist/coord.d.ts delete mode 100644 dist/coord.d.ts.map delete mode 100644 dist/coord.js delete mode 100644 dist/coord.js.map delete mode 100644 dist/esm/arc.js delete mode 100644 dist/esm/arc.js.map delete mode 100644 dist/esm/coord.js delete mode 100644 dist/esm/coord.js.map delete mode 100644 dist/esm/great-circle.js delete mode 100644 dist/esm/great-circle.js.map delete mode 100644 dist/esm/index.js delete mode 100644 dist/esm/index.js.map delete mode 100644 dist/esm/line-string.js delete mode 100644 dist/esm/line-string.js.map delete mode 100644 dist/esm/types.js delete mode 100644 dist/esm/types.js.map delete mode 100644 dist/esm/utils.js delete mode 100644 dist/esm/utils.js.map delete mode 100644 dist/great-circle.d.ts delete mode 100644 dist/great-circle.d.ts.map delete mode 100644 dist/great-circle.js delete mode 100644 dist/great-circle.js.map delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.d.ts.map delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 dist/line-string.d.ts delete mode 100644 dist/line-string.d.ts.map delete mode 100644 dist/line-string.js delete mode 100644 dist/line-string.js.map delete mode 100644 dist/types.d.ts delete mode 100644 dist/types.d.ts.map delete mode 100644 dist/types.js delete mode 100644 dist/types.js.map delete mode 100644 dist/utils.d.ts delete mode 100644 dist/utils.d.ts.map delete mode 100644 dist/utils.js delete mode 100644 dist/utils.js.map diff --git a/.gitignore b/.gitignore index bef8266..2a7be2b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ .DS_store node_modules coverage +dist/ +arc.js diff --git a/arc.js b/arc.js deleted file mode 100644 index 61fc2eb..0000000 --- a/arc.js +++ /dev/null @@ -1,363 +0,0 @@ -"use strict"; -var arc = (() => { - var __defProp = Object.defineProperty; - var __getOwnPropDesc = Object.getOwnPropertyDescriptor; - var __getOwnPropNames = Object.getOwnPropertyNames; - var __hasOwnProp = Object.prototype.hasOwnProperty; - var __export = (target, all) => { - for (var name in all) - __defProp(target, name, { get: all[name], enumerable: true }); - }; - var __copyProps = (to, from, except, desc) => { - if (from && typeof from === "object" || typeof from === "function") { - for (let key of __getOwnPropNames(from)) - if (!__hasOwnProp.call(to, key) && key !== except) - __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); - } - return to; - }; - var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); - - // src/index.ts - var index_exports = {}; - __export(index_exports, { - Arc: () => Arc, - Coord: () => Coord, - D2R: () => D2R, - GreatCircle: () => GreatCircle, - R2D: () => R2D, - _LineString: () => _LineString, - roundCoords: () => roundCoords - }); - - // src/utils.ts - function roundCoords(coords) { - const PRECISION = 6; - const MULTIPLIER = Math.pow(10, PRECISION); - const rounded = []; - for (let i = 0; i < coords.length; i++) { - const coord = coords[i]; - if (coord !== void 0) { - rounded[i] = Math.round( - (coord + Number.EPSILON) * MULTIPLIER - ) / MULTIPLIER; - } - } - return rounded; - } - var D2R = Math.PI / 180; - var R2D = 180 / Math.PI; - - // src/coord.ts - var Coord = class _Coord { - lon; - lat; - x; - y; - constructor(lon, lat) { - this.lon = lon; - this.lat = lat; - this.x = D2R * lon; - this.y = D2R * lat; - } - /** - * Get a string representation of the coordinate - * - * @returns String representation of the coordinate - * - * @example - * ```typescript - * const coord = new Coord(45.123456789, 50.987654321); - * console.log(coord.view()); // "45.123457,50.987654" - * ``` - */ - view() { - return String(this.lon).slice(0, 4) + "," + String(this.lat).slice(0, 4); - } - /** - * Get the antipodal point (diametrically opposite point on the sphere) - * - * @returns Antipodal point - * - * @example - * ```typescript - * const coord = new Coord(45.123456789, 50.987654321); - * console.log(coord.antipode()); // Coord { lon: -45.123457, lat: -50.987654 } - * ``` - */ - antipode() { - const anti_lat = -1 * this.lat; - const anti_lon = this.lon < 0 ? 180 + this.lon : (180 - this.lon) * -1; - return new _Coord(anti_lon, anti_lat); - } - }; - - // src/arc.ts - var Arc = class { - properties = {}; - geometries = []; - constructor(properties) { - if (properties) this.properties = properties; - } - /** - * Convert to GeoJSON Feature - * - * @returns GeoJSON Feature with LineString or MultiLineString geometry - * - * @example - * ```typescript - * const gc = new GreatCircle({x: -122, y: 48}, {x: -77, y: 39}); - * const arc = gc.Arc(3); - * console.log(arc.json()); - * // { type: 'Feature', geometry: { type: 'LineString', coordinates: [[-122, 48], [-99.5, 43.5], [-77, 39]] }, properties: {} } - * ``` - */ - json() { - if (this.geometries.length === 0) { - return { - type: "Feature", - // NOTE: coordinates: null is non-standard GeoJSON (RFC 7946 specifies empty array []) - // but maintained for backward compatibility with original arc.js behavior - geometry: { type: "LineString", coordinates: null }, - properties: this.properties - }; - } - if (this.geometries.length === 1) { - const firstGeometry = this.geometries[0]; - if (!firstGeometry) { - return { - type: "Feature", - geometry: { type: "LineString", coordinates: [] }, - properties: this.properties - }; - } - return { - type: "Feature", - geometry: { type: "LineString", coordinates: firstGeometry.coords }, - properties: this.properties - }; - } - const coordinates = this.geometries.filter((geom) => geom !== void 0).map((geom) => geom.coords); - return { - type: "Feature", - geometry: { type: "MultiLineString", coordinates }, - properties: this.properties - }; - } - /** - * Convert to WKT (Well Known Text) format - * - * @returns WKT string representation - * - * @example - * ```typescript - * const arc = new Arc({ name: 'test-arc' }); - * console.log(arc.wkt()); // "LINESTRING EMPTY" or "LINESTRING(lon lat,lon lat,...)" - * ``` - */ - wkt() { - if (this.geometries.length === 0) { - return ""; - } - let wktParts = []; - for (const geometry of this.geometries) { - if (!geometry || geometry.coords.length === 0) { - wktParts.push("LINESTRING EMPTY"); - continue; - } - const coordStrings = geometry.coords.filter((coord) => coord !== void 0).map((coord) => { - const lon = coord[0] ?? 0; - const lat = coord[1] ?? 0; - return `${lon} ${lat}`; - }); - if (coordStrings.length === 0) { - wktParts.push("LINESTRING EMPTY"); - } else { - wktParts.push(`LINESTRING(${coordStrings.join(",")})`); - } - } - return wktParts.join("; "); - } - }; - - // src/line-string.ts - var _LineString = class { - coords = []; - length = 0; - /** - * Add a coordinate to the line string - * - * @param coord - Coordinate position to add - */ - move_to(coord) { - this.length++; - this.coords.push(coord); - } - }; - - // src/great-circle.ts - var GreatCircle = class { - start; - end; - properties; - g; - constructor(start, end, properties) { - if (!start || start.x === void 0 || start.y === void 0) { - throw new Error("GreatCircle constructor expects two args: start and end objects with x and y properties"); - } - if (!end || end.x === void 0 || end.y === void 0) { - throw new Error("GreatCircle constructor expects two args: start and end objects with x and y properties"); - } - this.start = new Coord(start.x, start.y); - this.end = new Coord(end.x, end.y); - this.properties = properties || {}; - const w = this.start.x - this.end.x; - const h = this.start.y - this.end.y; - const z = Math.pow(Math.sin(h / 2), 2) + Math.cos(this.start.y) * Math.cos(this.end.y) * Math.pow(Math.sin(w / 2), 2); - this.g = 2 * Math.asin(Math.sqrt(z)); - if (this.g === Math.PI) { - throw new Error("it appears " + this.start.view() + " and " + this.end.view() + " are 'antipodal', e.g diametrically opposite, thus there is no single route but rather infinite"); - } else if (isNaN(this.g)) { - throw new Error("could not calculate great circle between " + start + " and " + end); - } - } - /** - * Interpolate along the great circle - * http://williams.best.vwh.net/avform.htm#Intermediate - * - * @param f - Interpolation factor - * @returns Interpolated point - * - * @example - * ```typescript - * const greatCircle = new GreatCircle({ x: 45.123456789, y: 50.987654321 }, { x: 46.123456789, y: 51.987654321 }); - * console.log(greatCircle.interpolate(0.5)); // [45.623457, 51.487654] - * ``` - */ - interpolate(f) { - const A = Math.sin((1 - f) * this.g) / Math.sin(this.g); - const B = Math.sin(f * this.g) / Math.sin(this.g); - const x = A * Math.cos(this.start.y) * Math.cos(this.start.x) + B * Math.cos(this.end.y) * Math.cos(this.end.x); - const y = A * Math.cos(this.start.y) * Math.sin(this.start.x) + B * Math.cos(this.end.y) * Math.sin(this.end.x); - const z = A * Math.sin(this.start.y) + B * Math.sin(this.end.y); - const lat = R2D * Math.atan2(z, Math.sqrt(Math.pow(x, 2) + Math.pow(y, 2))); - const lon = R2D * Math.atan2(y, x); - return [lon, lat]; - } - /** - * Generate points along the great circle - * - * @param npoints - Number of points to generate - * @param options - Optional options object - * @returns Arc object - * - * @example - * ```typescript - * const greatCircle = new GreatCircle({ x: 45.123456789, y: 50.987654321 }, { x: 46.123456789, y: 51.987654321 }); - * console.log(greatCircle.Arc(10)); // Arc { geometries: [ [Array] ] } - * ``` - */ - Arc(npoints, options) { - let first_pass = []; - if (!npoints || npoints <= 2) { - first_pass.push([this.start.lon, this.start.lat]); - first_pass.push([this.end.lon, this.end.lat]); - } else { - const delta = 1 / (npoints - 1); - for (let i = 0; i < npoints; ++i) { - const step = delta * i; - const pair = this.interpolate(step); - first_pass.push(pair); - } - } - let bHasBigDiff = false; - let dfMaxSmallDiffLong = 0; - const dfDateLineOffset = options?.offset ?? 10; - const dfLeftBorderX = 180 - dfDateLineOffset; - const dfRightBorderX = -180 + dfDateLineOffset; - const dfDiffSpace = 360 - dfDateLineOffset; - for (let j = 1; j < first_pass.length; ++j) { - const dfPrevX = first_pass[j - 1]?.[0] ?? 0; - const dfX = first_pass[j]?.[0] ?? 0; - const dfDiffLong = Math.abs(dfX - dfPrevX); - if (dfDiffLong > dfDiffSpace && (dfX > dfLeftBorderX && dfPrevX < dfRightBorderX || dfPrevX > dfLeftBorderX && dfX < dfRightBorderX)) { - bHasBigDiff = true; - } else if (dfDiffLong > dfMaxSmallDiffLong) { - dfMaxSmallDiffLong = dfDiffLong; - } - } - const poMulti = []; - if (bHasBigDiff && dfMaxSmallDiffLong < dfDateLineOffset) { - let poNewLS = []; - poMulti.push(poNewLS); - for (let k = 0; k < first_pass.length; ++k) { - const dfX0 = parseFloat((first_pass[k]?.[0] ?? 0).toString()); - if (k > 0 && Math.abs(dfX0 - (first_pass[k - 1]?.[0] ?? 0)) > dfDiffSpace) { - let dfX1 = parseFloat((first_pass[k - 1]?.[0] ?? 0).toString()); - let dfY1 = parseFloat((first_pass[k - 1]?.[1] ?? 0).toString()); - let dfX2 = parseFloat((first_pass[k]?.[0] ?? 0).toString()); - let dfY2 = parseFloat((first_pass[k]?.[1] ?? 0).toString()); - if (dfX1 > -180 && dfX1 < dfRightBorderX && dfX2 === 180 && k + 1 < first_pass.length && (first_pass[k - 1]?.[0] ?? 0) > -180 && (first_pass[k - 1]?.[0] ?? 0) < dfRightBorderX) { - poNewLS.push([-180, first_pass[k]?.[1] ?? 0]); - k++; - poNewLS.push([first_pass[k]?.[0] ?? 0, first_pass[k]?.[1] ?? 0]); - continue; - } else if (dfX1 > dfLeftBorderX && dfX1 < 180 && dfX2 === -180 && k + 1 < first_pass.length && (first_pass[k - 1]?.[0] ?? 0) > dfLeftBorderX && (first_pass[k - 1]?.[0] ?? 0) < 180) { - poNewLS.push([180, first_pass[k]?.[1] ?? 0]); - k++; - poNewLS.push([first_pass[k]?.[0] ?? 0, first_pass[k]?.[1] ?? 0]); - continue; - } - if (dfX1 < dfRightBorderX && dfX2 > dfLeftBorderX) { - const tmpX = dfX1; - dfX1 = dfX2; - dfX2 = tmpX; - const tmpY = dfY1; - dfY1 = dfY2; - dfY2 = tmpY; - } - if (dfX1 > dfLeftBorderX && dfX2 < dfRightBorderX) { - dfX2 += 360; - } - if (dfX1 <= 180 && dfX2 >= 180 && dfX1 < dfX2) { - const dfRatio = (180 - dfX1) / (dfX2 - dfX1); - const dfY = dfRatio * dfY2 + (1 - dfRatio) * dfY1; - poNewLS.push([(first_pass[k - 1]?.[0] ?? 0) > dfLeftBorderX ? 180 : -180, dfY]); - poNewLS = []; - poNewLS.push([(first_pass[k - 1]?.[0] ?? 0) > dfLeftBorderX ? -180 : 180, dfY]); - poMulti.push(poNewLS); - } else { - poNewLS = []; - poMulti.push(poNewLS); - } - poNewLS.push([dfX0, first_pass[k]?.[1] ?? 0]); - } else { - poNewLS.push([first_pass[k]?.[0] ?? 0, first_pass[k]?.[1] ?? 0]); - } - } - } else { - const poNewLS0 = []; - poMulti.push(poNewLS0); - for (let l = 0; l < first_pass.length; ++l) { - poNewLS0.push([first_pass[l]?.[0] ?? 0, first_pass[l]?.[1] ?? 0]); - } - } - const arc = new Arc(this.properties); - for (let m = 0; m < poMulti.length; ++m) { - const line = new _LineString(); - arc.geometries.push(line); - const points = poMulti[m]; - if (points) { - for (let j0 = 0; j0 < points.length; ++j0) { - const point = points[j0]; - if (point) { - line.move_to(roundCoords([point[0], point[1]])); - } - } - } - } - return arc; - } - }; - return __toCommonJS(index_exports); -})(); diff --git a/dist/arc.d.ts b/dist/arc.d.ts deleted file mode 100644 index 85ab017..0000000 --- a/dist/arc.d.ts +++ /dev/null @@ -1,45 +0,0 @@ -import { _LineString } from './line-string.js'; -import type { GeoJSONFeature } from './types.js'; -/** - * Arc class representing the result of great circle calculations - * - * @param properties - Optional properties object - * - * @example - * ```typescript - * const arc = new Arc({ x: 45.123456789, y: 50.987654321 }); - * console.log(arc.json()); // { type: 'Feature', geometry: { type: 'LineString', coordinates: [ [Array] ] }, properties: { x: 45.123457, y: 50.987654 } } - * ``` - */ -export declare class Arc { - properties: Record; - geometries: _LineString[]; - constructor(properties?: Record); - /** - * Convert to GeoJSON Feature - * - * @returns GeoJSON Feature with LineString or MultiLineString geometry - * - * @example - * ```typescript - * const gc = new GreatCircle({x: -122, y: 48}, {x: -77, y: 39}); - * const arc = gc.Arc(3); - * console.log(arc.json()); - * // { type: 'Feature', geometry: { type: 'LineString', coordinates: [[-122, 48], [-99.5, 43.5], [-77, 39]] }, properties: {} } - * ``` - */ - json(): GeoJSONFeature; - /** - * Convert to WKT (Well Known Text) format - * - * @returns WKT string representation - * - * @example - * ```typescript - * const arc = new Arc({ name: 'test-arc' }); - * console.log(arc.wkt()); // "LINESTRING EMPTY" or "LINESTRING(lon lat,lon lat,...)" - * ``` - */ - wkt(): string; -} -//# sourceMappingURL=arc.d.ts.map \ No newline at end of file diff --git a/dist/arc.d.ts.map b/dist/arc.d.ts.map deleted file mode 100644 index d93b487..0000000 --- a/dist/arc.d.ts.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"arc.d.ts","sourceRoot":"","sources":["../src/arc.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAGjD;;;;;;;;;;GAUG;AACH,qBAAa,GAAG;IACL,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAM;IACrC,UAAU,EAAE,WAAW,EAAE,CAAM;gBAE1B,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;IAI5C;;;;;;;;;;;;OAYG;IACH,IAAI,IAAI,cAAc;IA0CtB;;;;;;;;;;OAUG;IACH,GAAG,IAAI,MAAM;CA8BhB"} \ No newline at end of file diff --git a/dist/arc.js b/dist/arc.js deleted file mode 100644 index 1e19a0d..0000000 --- a/dist/arc.js +++ /dev/null @@ -1,111 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.Arc = void 0; -/** - * Arc class representing the result of great circle calculations - * - * @param properties - Optional properties object - * - * @example - * ```typescript - * const arc = new Arc({ x: 45.123456789, y: 50.987654321 }); - * console.log(arc.json()); // { type: 'Feature', geometry: { type: 'LineString', coordinates: [ [Array] ] }, properties: { x: 45.123457, y: 50.987654 } } - * ``` - */ -class Arc { - properties = {}; - geometries = []; - constructor(properties) { - if (properties) - this.properties = properties; - } - /** - * Convert to GeoJSON Feature - * - * @returns GeoJSON Feature with LineString or MultiLineString geometry - * - * @example - * ```typescript - * const gc = new GreatCircle({x: -122, y: 48}, {x: -77, y: 39}); - * const arc = gc.Arc(3); - * console.log(arc.json()); - * // { type: 'Feature', geometry: { type: 'LineString', coordinates: [[-122, 48], [-99.5, 43.5], [-77, 39]] }, properties: {} } - * ``` - */ - json() { - // Handle empty case - if (this.geometries.length === 0) { - return { - type: 'Feature', - // NOTE: coordinates: null is non-standard GeoJSON (RFC 7946 specifies empty array []) - // but maintained for backward compatibility with original arc.js behavior - geometry: { type: 'LineString', coordinates: null }, - properties: this.properties - }; - } - // Handle single LineString - if (this.geometries.length === 1) { - const firstGeometry = this.geometries[0]; - if (!firstGeometry) { - return { - type: 'Feature', - geometry: { type: 'LineString', coordinates: [] }, - properties: this.properties - }; - } - return { - type: 'Feature', - geometry: { type: 'LineString', coordinates: firstGeometry.coords }, - properties: this.properties - }; - } - // Handle multiple LineStrings as MultiLineString - const coordinates = this.geometries - .filter(geom => geom !== undefined) - .map(geom => geom.coords); - return { - type: 'Feature', - geometry: { type: 'MultiLineString', coordinates }, - properties: this.properties - }; - } - /** - * Convert to WKT (Well Known Text) format - * - * @returns WKT string representation - * - * @example - * ```typescript - * const arc = new Arc({ name: 'test-arc' }); - * console.log(arc.wkt()); // "LINESTRING EMPTY" or "LINESTRING(lon lat,lon lat,...)" - * ``` - */ - wkt() { - if (this.geometries.length === 0) { - return ''; - } - let wktParts = []; - for (const geometry of this.geometries) { - if (!geometry || geometry.coords.length === 0) { - wktParts.push('LINESTRING EMPTY'); - continue; - } - const coordStrings = geometry.coords - .filter(coord => coord !== undefined) - .map(coord => { - const lon = coord[0] ?? 0; - const lat = coord[1] ?? 0; - return `${lon} ${lat}`; - }); - if (coordStrings.length === 0) { - wktParts.push('LINESTRING EMPTY'); - } - else { - wktParts.push(`LINESTRING(${coordStrings.join(',')})`); - } - } - return wktParts.join('; '); - } -} -exports.Arc = Arc; -//# sourceMappingURL=arc.js.map \ No newline at end of file diff --git a/dist/arc.js.map b/dist/arc.js.map deleted file mode 100644 index d8a6ac7..0000000 --- a/dist/arc.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"arc.js","sourceRoot":"","sources":["../src/arc.ts"],"names":[],"mappings":";;;AAIA;;;;;;;;;;GAUG;AACH,MAAa,GAAG;IACL,UAAU,GAAwB,EAAE,CAAC;IACrC,UAAU,GAAkB,EAAE,CAAC;IAEtC,YAAY,UAAgC;QACxC,IAAI,UAAU;YAAE,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;IACjD,CAAC;IAED;;;;;;;;;;;;OAYG;IACH,IAAI;QACA,oBAAoB;QACpB,IAAI,IAAI,CAAC,UAAU,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YAC/B,OAAO;gBACH,IAAI,EAAE,SAAS;gBACf,sFAAsF;gBACtF,0EAA0E;gBAC1E,QAAQ,EAAE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EAAE,CAAC;YACrC,IAAI,CAAC,QAAQ,IAAI,QAAQ,CAAC,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;gBAC5C,QAAQ,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAC;gBAClC,SAAS;YACb,CAAC;YAED,MAAM,YAAY,GAAG,QAAQ,CAAC,MAAM;iBAC/B,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,KAAK,SAAS,CAAC;iBACpC,GAAG,CAAC,KAAK,CAAC,EAAE;gBACT,MAAM,GAAG,GAAG,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;gBAC1B,MAAM,GAAG,GAAG,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;gBAC1B,OAAO,GAAG,GAAG,IAAI,GAAG,EAAE,CAAC;YAC3B,CAAC,CAAC,CAAC;YAEP,IAAI,YAAY,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;gBAC5B,QAAQ,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAC;YACtC,CAAC;iBAAM,CAAC;gBACJ,QAAQ,CAAC,IAAI,CAAC,cAAc,YAAY,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;YAC3D,CAAC;QACL,CAAC;QAED,OAAO,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC/B,CAAC;CACJ;AAxGD,kBAwGC"} \ No newline at end of file diff --git a/dist/coord.d.ts b/dist/coord.d.ts deleted file mode 100644 index f7fc3e7..0000000 --- a/dist/coord.d.ts +++ /dev/null @@ -1,45 +0,0 @@ -/** - * Coordinate class representing a point with longitude and latitude - * - * @param lon - Longitude value - * @param lat - Latitude value - * - * @example - * ```typescript - * const coord = new Coord(45.123456789, 50.987654321); - * console.log(coord.lon); // 45.123457 - * console.log(coord.lat); // 50.987654 - * ``` - */ -export declare class Coord { - readonly lon: number; - readonly lat: number; - readonly x: number; - readonly y: number; - constructor(lon: number, lat: number); - /** - * Get a string representation of the coordinate - * - * @returns String representation of the coordinate - * - * @example - * ```typescript - * const coord = new Coord(45.123456789, 50.987654321); - * console.log(coord.view()); // "45.123457,50.987654" - * ``` - */ - view(): string; - /** - * Get the antipodal point (diametrically opposite point on the sphere) - * - * @returns Antipodal point - * - * @example - * ```typescript - * const coord = new Coord(45.123456789, 50.987654321); - * console.log(coord.antipode()); // Coord { lon: -45.123457, lat: -50.987654 } - * ``` - */ - antipode(): Coord; -} -//# sourceMappingURL=coord.d.ts.map \ No newline at end of file diff --git a/dist/coord.d.ts.map b/dist/coord.d.ts.map deleted file mode 100644 index 1f9f28f..0000000 --- a/dist/coord.d.ts.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"coord.d.ts","sourceRoot":"","sources":["../src/coord.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;GAYG;AACH,qBAAa,KAAK;IACd,SAAgB,GAAG,EAAE,MAAM,CAAC;IAC5B,SAAgB,GAAG,EAAE,MAAM,CAAC;IAC5B,SAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,SAAgB,CAAC,EAAE,MAAM,CAAC;gBAEd,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM;IAOpC;;;;;;;;;;OAUG;IACH,IAAI,IAAI,MAAM;IAId;;;;;;;;;;OAUG;IACH,QAAQ,IAAI,KAAK;CAKpB"} \ No newline at end of file diff --git a/dist/coord.js b/dist/coord.js deleted file mode 100644 index 15af5e3..0000000 --- a/dist/coord.js +++ /dev/null @@ -1,61 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.Coord = void 0; -const utils_js_1 = require("./utils.js"); -/** - * Coordinate class representing a point with longitude and latitude - * - * @param lon - Longitude value - * @param lat - Latitude value - * - * @example - * ```typescript - * const coord = new Coord(45.123456789, 50.987654321); - * console.log(coord.lon); // 45.123457 - * console.log(coord.lat); // 50.987654 - * ``` - */ -class Coord { - lon; - lat; - x; - y; - constructor(lon, lat) { - this.lon = lon; - this.lat = lat; - this.x = utils_js_1.D2R * lon; - this.y = utils_js_1.D2R * lat; - } - /** - * Get a string representation of the coordinate - * - * @returns String representation of the coordinate - * - * @example - * ```typescript - * const coord = new Coord(45.123456789, 50.987654321); - * console.log(coord.view()); // "45.123457,50.987654" - * ``` - */ - view() { - return String(this.lon).slice(0, 4) + ',' + String(this.lat).slice(0, 4); - } - /** - * Get the antipodal point (diametrically opposite point on the sphere) - * - * @returns Antipodal point - * - * @example - * ```typescript - * const coord = new Coord(45.123456789, 50.987654321); - * console.log(coord.antipode()); // Coord { lon: -45.123457, lat: -50.987654 } - * ``` - */ - antipode() { - const anti_lat = -1 * this.lat; - const anti_lon = (this.lon < 0) ? 180 + this.lon : (180 - this.lon) * -1; - return new Coord(anti_lon, anti_lat); - } -} -exports.Coord = Coord; -//# sourceMappingURL=coord.js.map \ No newline at end of file diff --git a/dist/coord.js.map b/dist/coord.js.map deleted file mode 100644 index 57ec790..0000000 --- a/dist/coord.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"coord.js","sourceRoot":"","sources":["../src/coord.ts"],"names":[],"mappings":";;;AAAA,yCAAiC;AAEjC;;;;;;;;;;;;GAYG;AACH,MAAa,KAAK;IACE,GAAG,CAAS;IACZ,GAAG,CAAS;IACZ,CAAC,CAAS;IACV,CAAC,CAAS;IAE1B,YAAY,GAAW,EAAE,GAAW;QAChC,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;QACf,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;QACf,IAAI,CAAC,CAAC,GAAG,cAAG,GAAG,GAAG,CAAC;QACnB,IAAI,CAAC,CAAC,GAAG,cAAG,GAAG,GAAG,CAAC;IACvB,CAAC;IAED;;;;;;;;;;OAUG;IACH,IAAI;QACA,OAAO,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,GAAG,GAAG,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IAC7E,CAAC;IAED;;;;;;;;;;OAUG;IACH,QAAQ;QACJ,MAAM,QAAQ,GAAG,CAAC,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC;QAC/B,MAAM,QAAQ,GAAG,CAAC,IAAI,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC;QACzE,OAAO,IAAI,KAAK,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;IACzC,CAAC;CACJ;AA5CD,sBA4CC"} \ No newline at end of file diff --git a/dist/esm/arc.js b/dist/esm/arc.js deleted file mode 100644 index 48d1d5a..0000000 --- a/dist/esm/arc.js +++ /dev/null @@ -1,107 +0,0 @@ -/** - * Arc class representing the result of great circle calculations - * - * @param properties - Optional properties object - * - * @example - * ```typescript - * const arc = new Arc({ x: 45.123456789, y: 50.987654321 }); - * console.log(arc.json()); // { type: 'Feature', geometry: { type: 'LineString', coordinates: [ [Array] ] }, properties: { x: 45.123457, y: 50.987654 } } - * ``` - */ -export class Arc { - properties = {}; - geometries = []; - constructor(properties) { - if (properties) - this.properties = properties; - } - /** - * Convert to GeoJSON Feature - * - * @returns GeoJSON Feature with LineString or MultiLineString geometry - * - * @example - * ```typescript - * const gc = new GreatCircle({x: -122, y: 48}, {x: -77, y: 39}); - * const arc = gc.Arc(3); - * console.log(arc.json()); - * // { type: 'Feature', geometry: { type: 'LineString', coordinates: [[-122, 48], [-99.5, 43.5], [-77, 39]] }, properties: {} } - * ``` - */ - json() { - // Handle empty case - if (this.geometries.length === 0) { - return { - type: 'Feature', - // NOTE: coordinates: null is non-standard GeoJSON (RFC 7946 specifies empty array []) - // but maintained for backward compatibility with original arc.js behavior - geometry: { type: 'LineString', coordinates: null }, - properties: this.properties - }; - } - // Handle single LineString - if (this.geometries.length === 1) { - const firstGeometry = this.geometries[0]; - if (!firstGeometry) { - return { - type: 'Feature', - geometry: { type: 'LineString', coordinates: [] }, - properties: this.properties - }; - } - return { - type: 'Feature', - geometry: { type: 'LineString', coordinates: firstGeometry.coords }, - properties: this.properties - }; - } - // Handle multiple LineStrings as MultiLineString - const coordinates = this.geometries - .filter(geom => geom !== undefined) - .map(geom => geom.coords); - return { - type: 'Feature', - geometry: { type: 'MultiLineString', coordinates }, - properties: this.properties - }; - } - /** - * Convert to WKT (Well Known Text) format - * - * @returns WKT string representation - * - * @example - * ```typescript - * const arc = new Arc({ name: 'test-arc' }); - * console.log(arc.wkt()); // "LINESTRING EMPTY" or "LINESTRING(lon lat,lon lat,...)" - * ``` - */ - wkt() { - if (this.geometries.length === 0) { - return ''; - } - let wktParts = []; - for (const geometry of this.geometries) { - if (!geometry || geometry.coords.length === 0) { - wktParts.push('LINESTRING EMPTY'); - continue; - } - const coordStrings = geometry.coords - .filter(coord => coord !== undefined) - .map(coord => { - const lon = coord[0] ?? 0; - const lat = coord[1] ?? 0; - return `${lon} ${lat}`; - }); - if (coordStrings.length === 0) { - wktParts.push('LINESTRING EMPTY'); - } - else { - wktParts.push(`LINESTRING(${coordStrings.join(',')})`); - } - } - return wktParts.join('; '); - } -} -//# sourceMappingURL=arc.js.map \ No newline at end of file diff --git a/dist/esm/arc.js.map b/dist/esm/arc.js.map deleted file mode 100644 index d009c05..0000000 --- a/dist/esm/arc.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"arc.js","sourceRoot":"","sources":["../../src/arc.ts"],"names":[],"mappings":"AAIA;;;;;;;;;;GAUG;AACH,MAAM,OAAO,GAAG;IACL,UAAU,GAAwB,EAAE,CAAC;IACrC,UAAU,GAAkB,EAAE,CAAC;IAEtC,YAAY,UAAgC;QACxC,IAAI,UAAU;YAAE,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;IACjD,CAAC;IAED;;;;;;;;;;;;OAYG;I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IAAI,CAAC,UAAU,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YAC/B,OAAO,EAAE,CAAC;QACd,CAAC;QAED,IAAI,QAAQ,GAAa,EAAE,CAAC;QAE5B,KAAK,MAAM,QAAQ,IAAI,IAAI,CAAC,UAAU,EAAE,CAAC;YACrC,IAAI,CAAC,QAAQ,IAAI,QAAQ,CAAC,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;gBAC5C,QAAQ,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAC;gBAClC,SAAS;YACb,CAAC;YAED,MAAM,YAAY,GAAG,QAAQ,CAAC,MAAM;iBAC/B,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,KAAK,SAAS,CAAC;iBACpC,GAAG,CAAC,KAAK,CAAC,EAAE;gBACT,MAAM,GAAG,GAAG,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;gBAC1B,MAAM,GAAG,GAAG,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;gBAC1B,OAAO,GAAG,GAAG,IAAI,GAAG,EAAE,CAAC;YAC3B,CAAC,CAAC,CAAC;YAEP,IAAI,YAAY,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;gBAC5B,QAAQ,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAC;YACtC,CAAC;iBAAM,CAAC;gBACJ,QAAQ,CAAC,IAAI,CAAC,cAAc,YAAY,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;YAC3D,CAAC;QACL,CAAC;QAED,OAAO,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC/B,CAAC;CACJ"} \ No newline at end of file diff --git a/dist/esm/coord.js b/dist/esm/coord.js deleted file mode 100644 index 0e1f648..0000000 --- a/dist/esm/coord.js +++ /dev/null @@ -1,57 +0,0 @@ -import { D2R } from './utils.js'; -/** - * Coordinate class representing a point with longitude and latitude - * - * @param lon - Longitude value - * @param lat - Latitude value - * - * @example - * ```typescript - * const coord = new Coord(45.123456789, 50.987654321); - * console.log(coord.lon); // 45.123457 - * console.log(coord.lat); // 50.987654 - * ``` - */ -export class Coord { - lon; - lat; - x; - y; - constructor(lon, lat) { - this.lon = lon; - this.lat = lat; - this.x = D2R * lon; - this.y = D2R * lat; - } - /** - * Get a string representation of the coordinate - * - * @returns String representation of the coordinate - * - * @example - * ```typescript - * const coord = new Coord(45.123456789, 50.987654321); - * console.log(coord.view()); // "45.123457,50.987654" - * ``` - */ - view() { - return String(this.lon).slice(0, 4) + ',' + String(this.lat).slice(0, 4); - } - /** - * Get the antipodal point (diametrically opposite point on the sphere) - * - * @returns Antipodal point - * - * @example - * ```typescript - * const coord = new Coord(45.123456789, 50.987654321); - * console.log(coord.antipode()); // Coord { lon: -45.123457, lat: -50.987654 } - * ``` - */ - antipode() { - const anti_lat = -1 * this.lat; - const anti_lon = (this.lon < 0) ? 180 + this.lon : (180 - this.lon) * -1; - return new Coord(anti_lon, anti_lat); - } -} -//# sourceMappingURL=coord.js.map \ No newline at end of file diff --git a/dist/esm/coord.js.map b/dist/esm/coord.js.map deleted file mode 100644 index 16b019d..0000000 --- a/dist/esm/coord.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"coord.js","sourceRoot":"","sources":["../../src/coord.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,YAAY,CAAC;AAEjC;;;;;;;;;;;;GAYG;AACH,MAAM,OAAO,KAAK;IACE,GAAG,CAAS;IACZ,GAAG,CAAS;IACZ,CAAC,CAAS;IACV,CAAC,CAAS;IAE1B,YAAY,GAAW,EAAE,GAAW;QAChC,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;QACf,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;QACf,IAAI,CAAC,CAAC,GAAG,GAAG,GAAG,GAAG,CAAC;QACnB,IAAI,CAAC,CAAC,GAAG,GAAG,GAAG,GAAG,CAAC;IACvB,CAAC;IAED;;;;;;;;;;OAUG;IACH,IAAI;QACA,OAAO,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,GAAG,GAAG,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IAC7E,CAAC;IAED;;;;;;;;;;OAUG;IACH,QAAQ;QACJ,MAAM,QAAQ,GAAG,CAAC,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC;QAC/B,MAAM,QAAQ,GAAG,CAAC,IAAI,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC;QACzE,OAAO,IAAI,KAAK,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;IACzC,CAAC;CACJ"} \ No newline at end of file diff --git a/dist/esm/great-circle.js b/dist/esm/great-circle.js deleted file mode 100644 index 404c754..0000000 --- a/dist/esm/great-circle.js +++ /dev/null @@ -1,218 +0,0 @@ -import { Coord } from './coord.js'; -import { Arc } from './arc.js'; -import { _LineString } from './line-string.js'; -import { roundCoords, R2D } from './utils.js'; -/* - * Portions of this file contain code ported from GDAL (Geospatial Data Abstraction Library) - * - * GDAL is licensed under the MIT/X11 license. - * See GDAL-LICENSE.md for the full license text. - * - * Original source: gdal/ogr/ogrgeometryfactory.cpp - * Repository: https://github.com/OSGeo/gdal - */ -/** - * Great Circle calculation class - * http://en.wikipedia.org/wiki/Great-circle_distance - * - * @param start - Start point - * @param end - End point - * @param properties - Optional properties object - * - * @example - * ```typescript - * const greatCircle = new GreatCircle({ x: 45.123456789, y: 50.987654321 }, { x: 46.123456789, y: 51.987654321 }); - * console.log(greatCircle.interpolate(0.5)); // [45.623457, 51.487654] - * ``` - */ -export class GreatCircle { - start; - end; - properties; - g; - constructor(start, end, properties) { - if (!start || start.x === undefined || start.y === undefined) { - throw new Error("GreatCircle constructor expects two args: start and end objects with x and y properties"); - } - if (!end || end.x === undefined || end.y === undefined) { - throw new Error("GreatCircle constructor expects two args: start and end objects with x and y properties"); - } - this.start = new Coord(start.x, start.y); - this.end = new Coord(end.x, end.y); - this.properties = properties || {}; - const w = this.start.x - this.end.x; - const h = this.start.y - this.end.y; - const z = Math.pow(Math.sin(h / 2.0), 2) + - Math.cos(this.start.y) * - Math.cos(this.end.y) * - Math.pow(Math.sin(w / 2.0), 2); - this.g = 2.0 * Math.asin(Math.sqrt(z)); - if (this.g === Math.PI) { - throw new Error('it appears ' + this.start.view() + ' and ' + this.end.view() + " are 'antipodal', e.g diametrically opposite, thus there is no single route but rather infinite"); - } - else if (isNaN(this.g)) { - throw new Error('could not calculate great circle between ' + start + ' and ' + end); - } - } - /** - * Interpolate along the great circle - * http://williams.best.vwh.net/avform.htm#Intermediate - * - * @param f - Interpolation factor - * @returns Interpolated point - * - * @example - * ```typescript - * const greatCircle = new GreatCircle({ x: 45.123456789, y: 50.987654321 }, { x: 46.123456789, y: 51.987654321 }); - * console.log(greatCircle.interpolate(0.5)); // [45.623457, 51.487654] - * ``` - */ - interpolate(f) { - const A = Math.sin((1 - f) * this.g) / Math.sin(this.g); - const B = Math.sin(f * this.g) / Math.sin(this.g); - const x = A * Math.cos(this.start.y) * Math.cos(this.start.x) + B * Math.cos(this.end.y) * Math.cos(this.end.x); - const y = A * Math.cos(this.start.y) * Math.sin(this.start.x) + B * Math.cos(this.end.y) * Math.sin(this.end.x); - const z = A * Math.sin(this.start.y) + B * Math.sin(this.end.y); - const lat = R2D * Math.atan2(z, Math.sqrt(Math.pow(x, 2) + Math.pow(y, 2))); - const lon = R2D * Math.atan2(y, x); - return [lon, lat]; - } - /** - * Generate points along the great circle - * - * @param npoints - Number of points to generate - * @param options - Optional options object - * @returns Arc object - * - * @example - * ```typescript - * const greatCircle = new GreatCircle({ x: 45.123456789, y: 50.987654321 }, { x: 46.123456789, y: 51.987654321 }); - * console.log(greatCircle.Arc(10)); // Arc { geometries: [ [Array] ] } - * ``` - */ - Arc(npoints, options) { - let first_pass = []; - if (!npoints || npoints <= 2) { - first_pass.push([this.start.lon, this.start.lat]); - first_pass.push([this.end.lon, this.end.lat]); - } - else { - const delta = 1.0 / (npoints - 1); - for (let i = 0; i < npoints; ++i) { - const step = delta * i; - const pair = this.interpolate(step); - first_pass.push(pair); - } - } - /* partial port of dateline handling from: - gdal/ogr/ogrgeometryfactory.cpp - - TODO - does not handle all wrapping scenarios yet - */ - let bHasBigDiff = false; - let dfMaxSmallDiffLong = 0; - // from http://www.gdal.org/ogr2ogr.html - // -datelineoffset: - // (starting with GDAL 1.10) offset from dateline in degrees (default long. = +/- 10deg, geometries within 170deg to -170deg will be splited) - const dfDateLineOffset = options?.offset ?? 10; - const dfLeftBorderX = 180 - dfDateLineOffset; - const dfRightBorderX = -180 + dfDateLineOffset; - const dfDiffSpace = 360 - dfDateLineOffset; - // https://github.com/OSGeo/gdal/blob/7bfb9c452a59aac958bff0c8386b891edf8154ca/gdal/ogr/ogrgeometryfactory.cpp#L2342 - for (let j = 1; j < first_pass.length; ++j) { - const dfPrevX = first_pass[j - 1]?.[0] ?? 0; - const dfX = first_pass[j]?.[0] ?? 0; - const dfDiffLong = Math.abs(dfX - dfPrevX); - if (dfDiffLong > dfDiffSpace && - ((dfX > dfLeftBorderX && dfPrevX < dfRightBorderX) || (dfPrevX > dfLeftBorderX && dfX < dfRightBorderX))) { - bHasBigDiff = true; - } - else if (dfDiffLong > dfMaxSmallDiffLong) { - dfMaxSmallDiffLong = dfDiffLong; - } - } - const poMulti = []; - if (bHasBigDiff && dfMaxSmallDiffLong < dfDateLineOffset) { - let poNewLS = []; - poMulti.push(poNewLS); - for (let k = 0; k < first_pass.length; ++k) { - const dfX0 = parseFloat((first_pass[k]?.[0] ?? 0).toString()); - if (k > 0 && Math.abs(dfX0 - (first_pass[k - 1]?.[0] ?? 0)) > dfDiffSpace) { - let dfX1 = parseFloat((first_pass[k - 1]?.[0] ?? 0).toString()); - let dfY1 = parseFloat((first_pass[k - 1]?.[1] ?? 0).toString()); - let dfX2 = parseFloat((first_pass[k]?.[0] ?? 0).toString()); - let dfY2 = parseFloat((first_pass[k]?.[1] ?? 0).toString()); - if (dfX1 > -180 && dfX1 < dfRightBorderX && dfX2 === 180 && - k + 1 < first_pass.length && - (first_pass[k - 1]?.[0] ?? 0) > -180 && (first_pass[k - 1]?.[0] ?? 0) < dfRightBorderX) { - poNewLS.push([-180, first_pass[k]?.[1] ?? 0]); - k++; - poNewLS.push([first_pass[k]?.[0] ?? 0, first_pass[k]?.[1] ?? 0]); - continue; - } - else if (dfX1 > dfLeftBorderX && dfX1 < 180 && dfX2 === -180 && - k + 1 < first_pass.length && - (first_pass[k - 1]?.[0] ?? 0) > dfLeftBorderX && (first_pass[k - 1]?.[0] ?? 0) < 180) { - poNewLS.push([180, first_pass[k]?.[1] ?? 0]); - k++; - poNewLS.push([first_pass[k]?.[0] ?? 0, first_pass[k]?.[1] ?? 0]); - continue; - } - if (dfX1 < dfRightBorderX && dfX2 > dfLeftBorderX) { - // swap dfX1, dfX2 - const tmpX = dfX1; - dfX1 = dfX2; - dfX2 = tmpX; - // swap dfY1, dfY2 - const tmpY = dfY1; - dfY1 = dfY2; - dfY2 = tmpY; - } - if (dfX1 > dfLeftBorderX && dfX2 < dfRightBorderX) { - dfX2 += 360; - } - if (dfX1 <= 180 && dfX2 >= 180 && dfX1 < dfX2) { - const dfRatio = (180 - dfX1) / (dfX2 - dfX1); - const dfY = dfRatio * dfY2 + (1 - dfRatio) * dfY1; - poNewLS.push([(first_pass[k - 1]?.[0] ?? 0) > dfLeftBorderX ? 180 : -180, dfY]); - poNewLS = []; - poNewLS.push([(first_pass[k - 1]?.[0] ?? 0) > dfLeftBorderX ? -180 : 180, dfY]); - poMulti.push(poNewLS); - } - else { - poNewLS = []; - poMulti.push(poNewLS); - } - poNewLS.push([dfX0, first_pass[k]?.[1] ?? 0]); - } - else { - poNewLS.push([first_pass[k]?.[0] ?? 0, first_pass[k]?.[1] ?? 0]); - } - } - } - else { - // add normally - const poNewLS0 = []; - poMulti.push(poNewLS0); - for (let l = 0; l < first_pass.length; ++l) { - poNewLS0.push([first_pass[l]?.[0] ?? 0, first_pass[l]?.[1] ?? 0]); - } - } - const arc = new Arc(this.properties); - for (let m = 0; m < poMulti.length; ++m) { - const line = new _LineString(); - arc.geometries.push(line); - const points = poMulti[m]; - if (points) { - for (let j0 = 0; j0 < points.length; ++j0) { - const point = points[j0]; - if (point) { - line.move_to(roundCoords([point[0], point[1]])); - } - } - } - } - return arc; - } -} -//# sourceMappingURL=great-circle.js.map \ No newline at end of file diff --git a/dist/esm/great-circle.js.map b/dist/esm/great-circle.js.map deleted file mode 100644 index c47c78e..0000000 --- a/dist/esm/great-circle.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"great-circle.js","sourceRoot":"","sources":["../../src/great-circle.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACnC,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AAC/B,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,WAAW,EAAE,GAAG,EAAE,MAAM,YAAY,CAAC;AAE9C;;;;;;;;GAQG;AAEH;;;;;;;;;;;;;GAaG;AACH,MAAM,OAAO,WAAW;IACJ,KAAK,CAAQ;IACb,GAAG,CAAQ;IACX,UAAU,CAAsB;IAC/B,CAAC,CAAS;IAE3B,YAAY,KAAsB,EAAE,GAAoB,EAAE,UAAgC;QACtF,IAAI,CAAC,KAAK,IAAI,KAAK,CAAC,CAAC,KAAK,SAAS,IAAI,KAAK,CAAC,CAAC,KAAK,SAAS,EAAE,CAAC;YAC3D,MAAM,IAAI,KAAK,CAAC,yFAAyF,CAAC,CAAC;QAC/G,CAAC;QACD,IAAI,CAAC,GAAG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B,GAAG,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YAC1B,MAAM,MAAM,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;YAC1B,IAAI,MAAM,EAAE,CAAC;gBACT,KAAK,IAAI,EAAE,GAAG,CAAC,EAAE,EAAE,GAAG,MAAM,CAAC,MAAM,EAAE,EAAE,EAAE,EAAE,CAAC;oBACxC,MAAM,KAAK,GAAG,MAAM,CAAC,EAAE,CAAC,CAAC;oBACzB,IAAI,KAAK,EAAE,CAAC;wBACR,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;oBACpD,CAAC;gBACL,CAAC;YACL,CAAC;QACL,CAAC;QACD,OAAO,GAAG,CAAC;IACf,CAAC;CACJ"} \ No newline at end of file diff --git a/dist/esm/index.js b/dist/esm/index.js deleted file mode 100644 index 7dcd881..0000000 --- a/dist/esm/index.js +++ /dev/null @@ -1,7 +0,0 @@ -// Dual module exports (works for both CommonJS and ESM) -export { Coord } from './coord.js'; -export { Arc } from './arc.js'; -export { GreatCircle } from './great-circle.js'; -export { roundCoords, D2R, R2D } from './utils.js'; -export { _LineString } from './line-string.js'; -//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/dist/esm/index.js.map b/dist/esm/index.js.map deleted file mode 100644 index 8ca7df3..0000000 --- a/dist/esm/index.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACnC,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AAC/B,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,WAAW,EAAE,GAAG,EAAE,GAAG,EAAE,MAAM,YAAY,CAAC;AACnD,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC"} \ No newline at end of file diff --git a/dist/esm/line-string.js b/dist/esm/line-string.js deleted file mode 100644 index a90b4a6..0000000 --- a/dist/esm/line-string.js +++ /dev/null @@ -1,17 +0,0 @@ -/** - * Internal LineString class for building geometries - */ -export class _LineString { - coords = []; - length = 0; - /** - * Add a coordinate to the line string - * - * @param coord - Coordinate position to add - */ - move_to(coord) { - this.length++; - this.coords.push(coord); - } -} -//# sourceMappingURL=line-string.js.map \ No newline at end of file diff --git a/dist/esm/line-string.js.map b/dist/esm/line-string.js.map deleted file mode 100644 index ed78a83..0000000 --- a/dist/esm/line-string.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"line-string.js","sourceRoot":"","sources":["../../src/line-string.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,MAAM,OAAO,WAAW;IACb,MAAM,GAAe,EAAE,CAAC;IACxB,MAAM,GAAW,CAAC,CAAC;IAE1B;;;;OAIG;IACH,OAAO,CAAC,KAAe;QACnB,IAAI,CAAC,MAAM,EAAE,CAAC;QACd,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAC5B,CAAC;CACJ"} \ No newline at end of file diff --git a/dist/esm/types.js b/dist/esm/types.js deleted file mode 100644 index 718fd38..0000000 --- a/dist/esm/types.js +++ /dev/null @@ -1,2 +0,0 @@ -export {}; -//# sourceMappingURL=types.js.map \ No newline at end of file diff --git a/dist/esm/types.js.map b/dist/esm/types.js.map deleted file mode 100644 index 7b5fff8..0000000 --- a/dist/esm/types.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":""} \ No newline at end of file diff --git a/dist/esm/utils.js b/dist/esm/utils.js deleted file mode 100644 index 4bbd546..0000000 --- a/dist/esm/utils.js +++ /dev/null @@ -1,36 +0,0 @@ -/** - * Round coordinate decimal values to 6 places for precision - * - * @param coords - A coordinate position (longitude, latitude, optional elevation) - * @returns Rounded coordinate position - * - * @example - * ```typescript - * const coords = [45.123456789, 50.987654321]; - * const roundedCoords = roundCoords(coords); - * console.log(roundedCoords); // [45.123457, 50.987654] - * ``` - */ -export function roundCoords(coords) { - // round coordinate decimal values to 6 places - const PRECISION = 6; - const MULTIPLIER = Math.pow(10, PRECISION); - const rounded = []; - for (let i = 0; i < coords.length; i++) { - const coord = coords[i]; - if (coord !== undefined) { - // https://stackoverflow.com/questions/11832914/how-to-round-to-at-most-2-decimal-places-if-necessary - rounded[i] = Math.round((coord + Number.EPSILON) * MULTIPLIER) / MULTIPLIER; - } - } - return rounded; -} -/** - * Convert degrees to radians - */ -export const D2R = Math.PI / 180; -/** - * Convert radians to degrees - */ -export const R2D = 180 / Math.PI; -//# sourceMappingURL=utils.js.map \ No newline at end of file diff --git a/dist/esm/utils.js.map b/dist/esm/utils.js.map deleted file mode 100644 index ac9c076..0000000 --- a/dist/esm/utils.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/utils.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,WAAW,CAAC,MAAgB;IACxC,8CAA8C;IAC9C,MAAM,SAAS,GAAG,CAAC,CAAC;IACpB,MAAM,UAAU,GAAG,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,SAAS,CAAC,CAAC;IAE3C,MAAM,OAAO,GAAa,EAAE,CAAC;IAC7B,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QACrC,MAAM,KAAK,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC;QACxB,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;YACtB,qGAAqG;YACrG,OAAO,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,KAAK,CACnB,CAAC,KAAK,GAAG,MAAM,CAAC,OAAO,CAAC,GAAG,UAAU,CACxC,GAAG,UAAU,CAAC;QACnB,CAAC;IACL,CAAC;IAED,OAAO,OAAO,CAAC;AACnB,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,MAAM,GAAG,GAAG,IAAI,CAAC,EAAE,GAAG,GAAG,CAAC;AAEjC;;GAEG;AACH,MAAM,CAAC,MAAM,GAAG,GAAG,GAAG,GAAG,IAAI,CAAC,EAAE,CAAC"} \ No newline at end of file diff --git a/dist/great-circle.d.ts b/dist/great-circle.d.ts deleted file mode 100644 index 560d6b4..0000000 --- a/dist/great-circle.d.ts +++ /dev/null @@ -1,53 +0,0 @@ -import type { CoordinatePoint, ArcOptions } from './types.js'; -import { Coord } from './coord.js'; -import { Arc } from './arc.js'; -/** - * Great Circle calculation class - * http://en.wikipedia.org/wiki/Great-circle_distance - * - * @param start - Start point - * @param end - End point - * @param properties - Optional properties object - * - * @example - * ```typescript - * const greatCircle = new GreatCircle({ x: 45.123456789, y: 50.987654321 }, { x: 46.123456789, y: 51.987654321 }); - * console.log(greatCircle.interpolate(0.5)); // [45.623457, 51.487654] - * ``` - */ -export declare class GreatCircle { - readonly start: Coord; - readonly end: Coord; - readonly properties: Record; - private readonly g; - constructor(start: CoordinatePoint, end: CoordinatePoint, properties?: Record); - /** - * Interpolate along the great circle - * http://williams.best.vwh.net/avform.htm#Intermediate - * - * @param f - Interpolation factor - * @returns Interpolated point - * - * @example - * ```typescript - * const greatCircle = new GreatCircle({ x: 45.123456789, y: 50.987654321 }, { x: 46.123456789, y: 51.987654321 }); - * console.log(greatCircle.interpolate(0.5)); // [45.623457, 51.487654] - * ``` - */ - interpolate(f: number): [number, number]; - /** - * Generate points along the great circle - * - * @param npoints - Number of points to generate - * @param options - Optional options object - * @returns Arc object - * - * @example - * ```typescript - * const greatCircle = new GreatCircle({ x: 45.123456789, y: 50.987654321 }, { x: 46.123456789, y: 51.987654321 }); - * console.log(greatCircle.Arc(10)); // Arc { geometries: [ [Array] ] } - * ``` - */ - Arc(npoints?: number, options?: ArcOptions): Arc; -} -//# sourceMappingURL=great-circle.d.ts.map \ No newline at end of file diff --git a/dist/great-circle.d.ts.map b/dist/great-circle.d.ts.map deleted file mode 100644 index fd795f3..0000000 --- a/dist/great-circle.d.ts.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"great-circle.d.ts","sourceRoot":"","sources":["../src/great-circle.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAC9D,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACnC,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AAc/B;;;;;;;;;;;;;GAaG;AACH,qBAAa,WAAW;IACpB,SAAgB,KAAK,EAAE,KAAK,CAAC;IAC7B,SAAgB,GAAG,EAAE,KAAK,CAAC;IAC3B,SAAgB,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAChD,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAS;gBAEf,KAAK,EAAE,eAAe,EAAE,GAAG,EAAE,eAAe,EAAE,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;IA2B1F;;;;;;;;;;;;OAYG;IACH,WAAW,CAAC,CAAC,EAAE,MAAM,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC;IAWxC;;;;;;;;;;;;OAYG;IACH,GAAG,CAAC,OAAO,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,UAAU,GAAG,GAAG;CAmInD"} \ No newline at end of file diff --git a/dist/great-circle.js b/dist/great-circle.js deleted file mode 100644 index 2958800..0000000 --- a/dist/great-circle.js +++ /dev/null @@ -1,222 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.GreatCircle = void 0; -const coord_js_1 = require("./coord.js"); -const arc_js_1 = require("./arc.js"); -const line_string_js_1 = require("./line-string.js"); -const utils_js_1 = require("./utils.js"); -/* - * Portions of this file contain code ported from GDAL (Geospatial Data Abstraction Library) - * - * GDAL is licensed under the MIT/X11 license. - * See GDAL-LICENSE.md for the full license text. - * - * Original source: gdal/ogr/ogrgeometryfactory.cpp - * Repository: https://github.com/OSGeo/gdal - */ -/** - * Great Circle calculation class - * http://en.wikipedia.org/wiki/Great-circle_distance - * - * @param start - Start point - * @param end - End point - * @param properties - Optional properties object - * - * @example - * ```typescript - * const greatCircle = new GreatCircle({ x: 45.123456789, y: 50.987654321 }, { x: 46.123456789, y: 51.987654321 }); - * console.log(greatCircle.interpolate(0.5)); // [45.623457, 51.487654] - * ``` - */ -class GreatCircle { - start; - end; - properties; - g; - constructor(start, end, properties) { - if (!start || start.x === undefined || start.y === undefined) { - throw new Error("GreatCircle constructor expects two args: start and end objects with x and y properties"); - } - if (!end || end.x === undefined || end.y === undefined) { - throw new Error("GreatCircle constructor expects two args: start and end objects with x and y properties"); - } - this.start = new coord_js_1.Coord(start.x, start.y); - this.end = new coord_js_1.Coord(end.x, end.y); - this.properties = properties || {}; - const w = this.start.x - this.end.x; - const h = this.start.y - this.end.y; - const z = Math.pow(Math.sin(h / 2.0), 2) + - Math.cos(this.start.y) * - Math.cos(this.end.y) * - Math.pow(Math.sin(w / 2.0), 2); - this.g = 2.0 * Math.asin(Math.sqrt(z)); - if (this.g === Math.PI) { - throw new Error('it appears ' + this.start.view() + ' and ' + this.end.view() + " are 'antipodal', e.g diametrically opposite, thus there is no single route but rather infinite"); - } - else if (isNaN(this.g)) { - throw new Error('could not calculate great circle between ' + start + ' and ' + end); - } - } - /** - * Interpolate along the great circle - * http://williams.best.vwh.net/avform.htm#Intermediate - * - * @param f - Interpolation factor - * @returns Interpolated point - * - * @example - * ```typescript - * const greatCircle = new GreatCircle({ x: 45.123456789, y: 50.987654321 }, { x: 46.123456789, y: 51.987654321 }); - * console.log(greatCircle.interpolate(0.5)); // [45.623457, 51.487654] - * ``` - */ - interpolate(f) { - const A = Math.sin((1 - f) * this.g) / Math.sin(this.g); - const B = Math.sin(f * this.g) / Math.sin(this.g); - const x = A * Math.cos(this.start.y) * Math.cos(this.start.x) + B * Math.cos(this.end.y) * Math.cos(this.end.x); - const y = A * Math.cos(this.start.y) * Math.sin(this.start.x) + B * Math.cos(this.end.y) * Math.sin(this.end.x); - const z = A * Math.sin(this.start.y) + B * Math.sin(this.end.y); - const lat = utils_js_1.R2D * Math.atan2(z, Math.sqrt(Math.pow(x, 2) + Math.pow(y, 2))); - const lon = utils_js_1.R2D * Math.atan2(y, x); - return [lon, lat]; - } - /** - * Generate points along the great circle - * - * @param npoints - Number of points to generate - * @param options - Optional options object - * @returns Arc object - * - * @example - * ```typescript - * const greatCircle = new GreatCircle({ x: 45.123456789, y: 50.987654321 }, { x: 46.123456789, y: 51.987654321 }); - * console.log(greatCircle.Arc(10)); // Arc { geometries: [ [Array] ] } - * ``` - */ - Arc(npoints, options) { - let first_pass = []; - if (!npoints || npoints <= 2) { - first_pass.push([this.start.lon, this.start.lat]); - first_pass.push([this.end.lon, this.end.lat]); - } - else { - const delta = 1.0 / (npoints - 1); - for (let i = 0; i < npoints; ++i) { - const step = delta * i; - const pair = this.interpolate(step); - first_pass.push(pair); - } - } - /* partial port of dateline handling from: - gdal/ogr/ogrgeometryfactory.cpp - - TODO - does not handle all wrapping scenarios yet - */ - let bHasBigDiff = false; - let dfMaxSmallDiffLong = 0; - // from http://www.gdal.org/ogr2ogr.html - // -datelineoffset: - // (starting with GDAL 1.10) offset from dateline in degrees (default long. = +/- 10deg, geometries within 170deg to -170deg will be splited) - const dfDateLineOffset = options?.offset ?? 10; - const dfLeftBorderX = 180 - dfDateLineOffset; - const dfRightBorderX = -180 + dfDateLineOffset; - const dfDiffSpace = 360 - dfDateLineOffset; - // https://github.com/OSGeo/gdal/blob/7bfb9c452a59aac958bff0c8386b891edf8154ca/gdal/ogr/ogrgeometryfactory.cpp#L2342 - for (let j = 1; j < first_pass.length; ++j) { - const dfPrevX = first_pass[j - 1]?.[0] ?? 0; - const dfX = first_pass[j]?.[0] ?? 0; - const dfDiffLong = Math.abs(dfX - dfPrevX); - if (dfDiffLong > dfDiffSpace && - ((dfX > dfLeftBorderX && dfPrevX < dfRightBorderX) || (dfPrevX > dfLeftBorderX && dfX < dfRightBorderX))) { - bHasBigDiff = true; - } - else if (dfDiffLong > dfMaxSmallDiffLong) { - dfMaxSmallDiffLong = dfDiffLong; - } - } - const poMulti = []; - if (bHasBigDiff && dfMaxSmallDiffLong < dfDateLineOffset) { - let poNewLS = []; - poMulti.push(poNewLS); - for (let k = 0; k < first_pass.length; ++k) { - const dfX0 = parseFloat((first_pass[k]?.[0] ?? 0).toString()); - if (k > 0 && Math.abs(dfX0 - (first_pass[k - 1]?.[0] ?? 0)) > dfDiffSpace) { - let dfX1 = parseFloat((first_pass[k - 1]?.[0] ?? 0).toString()); - let dfY1 = parseFloat((first_pass[k - 1]?.[1] ?? 0).toString()); - let dfX2 = parseFloat((first_pass[k]?.[0] ?? 0).toString()); - let dfY2 = parseFloat((first_pass[k]?.[1] ?? 0).toString()); - if (dfX1 > -180 && dfX1 < dfRightBorderX && dfX2 === 180 && - k + 1 < first_pass.length && - (first_pass[k - 1]?.[0] ?? 0) > -180 && (first_pass[k - 1]?.[0] ?? 0) < dfRightBorderX) { - poNewLS.push([-180, first_pass[k]?.[1] ?? 0]); - k++; - poNewLS.push([first_pass[k]?.[0] ?? 0, first_pass[k]?.[1] ?? 0]); - continue; - } - else if (dfX1 > dfLeftBorderX && dfX1 < 180 && dfX2 === -180 && - k + 1 < first_pass.length && - (first_pass[k - 1]?.[0] ?? 0) > dfLeftBorderX && (first_pass[k - 1]?.[0] ?? 0) < 180) { - poNewLS.push([180, first_pass[k]?.[1] ?? 0]); - k++; - poNewLS.push([first_pass[k]?.[0] ?? 0, first_pass[k]?.[1] ?? 0]); - continue; - } - if (dfX1 < dfRightBorderX && dfX2 > dfLeftBorderX) { - // swap dfX1, dfX2 - const tmpX = dfX1; - dfX1 = dfX2; - dfX2 = tmpX; - // swap dfY1, dfY2 - const tmpY = dfY1; - dfY1 = dfY2; - dfY2 = tmpY; - } - if (dfX1 > dfLeftBorderX && dfX2 < dfRightBorderX) { - dfX2 += 360; - } - if (dfX1 <= 180 && dfX2 >= 180 && dfX1 < dfX2) { - const dfRatio = (180 - dfX1) / (dfX2 - dfX1); - const dfY = dfRatio * dfY2 + (1 - dfRatio) * dfY1; - poNewLS.push([(first_pass[k - 1]?.[0] ?? 0) > dfLeftBorderX ? 180 : -180, dfY]); - poNewLS = []; - poNewLS.push([(first_pass[k - 1]?.[0] ?? 0) > dfLeftBorderX ? -180 : 180, dfY]); - poMulti.push(poNewLS); - } - else { - poNewLS = []; - poMulti.push(poNewLS); - } - poNewLS.push([dfX0, first_pass[k]?.[1] ?? 0]); - } - else { - poNewLS.push([first_pass[k]?.[0] ?? 0, first_pass[k]?.[1] ?? 0]); - } - } - } - else { - // add normally - const poNewLS0 = []; - poMulti.push(poNewLS0); - for (let l = 0; l < first_pass.length; ++l) { - poNewLS0.push([first_pass[l]?.[0] ?? 0, first_pass[l]?.[1] ?? 0]); - } - } - const arc = new arc_js_1.Arc(this.properties); - for (let m = 0; m < poMulti.length; ++m) { - const line = new line_string_js_1._LineString(); - arc.geometries.push(line); - const points = poMulti[m]; - if (points) { - for (let j0 = 0; j0 < points.length; ++j0) { - const point = points[j0]; - if (point) { - line.move_to((0, utils_js_1.roundCoords)([point[0], point[1]])); - } - } - } - } - return arc; - } -} -exports.GreatCircle = GreatCircle; -//# sourceMappingURL=great-circle.js.map \ No newline at end of file diff --git a/dist/great-circle.js.map b/dist/great-circle.js.map deleted file mode 100644 index 3b1d49e..0000000 --- a/dist/great-circle.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"great-circle.js","sourceRoot":"","sources":["../src/great-circle.ts"],"names":[],"mappings":";;;AACA,yCAAmC;AACnC,qCAA+B;AAC/B,qDAA+C;AAC/C,yCAA8C;AAE9C;;;;;;;;GAQG;AAEH;;;;;;;;;;;;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AI,CAAC,EAAE,UAAU,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;YACtE,CAAC;QACL,CAAC;QAED,MAAM,GAAG,GAAG,IAAI,YAAG,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;QACrC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,EAAE,CAAC;YACtC,MAAM,IAAI,GAAG,IAAI,4BAAW,EAAE,CAAC;YAC/B,GAAG,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YAC1B,MAAM,MAAM,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;YAC1B,IAAI,MAAM,EAAE,CAAC;gBACT,KAAK,IAAI,EAAE,GAAG,CAAC,EAAE,EAAE,GAAG,MAAM,CAAC,MAAM,EAAE,EAAE,EAAE,EAAE,CAAC;oBACxC,MAAM,KAAK,GAAG,MAAM,CAAC,EAAE,CAAC,CAAC;oBACzB,IAAI,KAAK,EAAE,CAAC;wBACR,IAAI,CAAC,OAAO,CAAC,IAAA,sBAAW,EAAC,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;oBACpD,CAAC;gBACL,CAAC;YACL,CAAC;QACL,CAAC;QACD,OAAO,GAAG,CAAC;IACf,CAAC;CACJ;AAzMD,kCAyMC"} \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index 4a76f55..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,7 +0,0 @@ -export { Coord } from './coord.js'; -export { Arc } from './arc.js'; -export { GreatCircle } from './great-circle.js'; -export { roundCoords, D2R, R2D } from './utils.js'; -export { _LineString } from './line-string.js'; -export type { CoordinatePoint, ArcOptions, GeoJSONFeature, LineString, MultiLineString } from './types.js'; -//# sourceMappingURL=index.d.ts.map \ No newline at end of file diff --git a/dist/index.d.ts.map b/dist/index.d.ts.map deleted file mode 100644 index ee8a4b6..0000000 --- a/dist/index.d.ts.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACnC,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AAC/B,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,WAAW,EAAE,GAAG,EAAE,GAAG,EAAE,MAAM,YAAY,CAAC;AACnD,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAG/C,YAAY,EAAE,eAAe,EAAE,UAAU,EAAE,cAAc,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC"} \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 672f184..0000000 --- a/dist/index.js +++ /dev/null @@ -1,17 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports._LineString = exports.R2D = exports.D2R = exports.roundCoords = exports.GreatCircle = exports.Arc = exports.Coord = void 0; -// Dual module exports (works for both CommonJS and ESM) -var coord_js_1 = require("./coord.js"); -Object.defineProperty(exports, "Coord", { enumerable: true, get: function () { return coord_js_1.Coord; } }); -var arc_js_1 = require("./arc.js"); -Object.defineProperty(exports, "Arc", { enumerable: true, get: function () { return arc_js_1.Arc; } }); -var great_circle_js_1 = require("./great-circle.js"); -Object.defineProperty(exports, "GreatCircle", { enumerable: true, get: function () { return great_circle_js_1.GreatCircle; } }); -var utils_js_1 = require("./utils.js"); -Object.defineProperty(exports, "roundCoords", { enumerable: true, get: function () { return utils_js_1.roundCoords; } }); -Object.defineProperty(exports, "D2R", { enumerable: true, get: function () { return utils_js_1.D2R; } }); -Object.defineProperty(exports, "R2D", { enumerable: true, get: function () { return utils_js_1.R2D; } }); -var line_string_js_1 = require("./line-string.js"); -Object.defineProperty(exports, "_LineString", { enumerable: true, get: function () { return line_string_js_1._LineString; } }); -//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index da9522b..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,wDAAwD;AACxD,uCAAmC;AAA1B,iGAAA,KAAK,OAAA;AACd,mCAA+B;AAAtB,6FAAA,GAAG,OAAA;AACZ,qDAAgD;AAAvC,8GAAA,WAAW,OAAA;AACpB,uCAAmD;AAA1C,uGAAA,WAAW,OAAA;AAAE,+FAAA,GAAG,OAAA;AAAE,+FAAA,GAAG,OAAA;AAC9B,mDAA+C;AAAtC,6GAAA,WAAW,OAAA"} \ No newline at end of file diff --git a/dist/line-string.d.ts b/dist/line-string.d.ts deleted file mode 100644 index f2aaff1..0000000 --- a/dist/line-string.d.ts +++ /dev/null @@ -1,15 +0,0 @@ -import type { Position } from './types.js'; -/** - * Internal LineString class for building geometries - */ -export declare class _LineString { - coords: Position[]; - length: number; - /** - * Add a coordinate to the line string - * - * @param coord - Coordinate position to add - */ - move_to(coord: Position): void; -} -//# sourceMappingURL=line-string.d.ts.map \ No newline at end of file diff --git a/dist/line-string.d.ts.map b/dist/line-string.d.ts.map deleted file mode 100644 index 6d02d8f..0000000 --- a/dist/line-string.d.ts.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"line-string.d.ts","sourceRoot":"","sources":["../src/line-string.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAE3C;;GAEG;AACH,qBAAa,WAAW;IACb,MAAM,EAAE,QAAQ,EAAE,CAAM;IACxB,MAAM,EAAE,MAAM,CAAK;IAE1B;;;;OAIG;IACH,OAAO,CAAC,KAAK,EAAE,QAAQ,GAAG,IAAI;CAIjC"} \ No newline at end of file diff --git a/dist/line-string.js b/dist/line-string.js deleted file mode 100644 index 7c3ff85..0000000 --- a/dist/line-string.js +++ /dev/null @@ -1,21 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports._LineString = void 0; -/** - * Internal LineString class for building geometries - */ -class _LineString { - coords = []; - length = 0; - /** - * Add a coordinate to the line string - * - * @param coord - Coordinate position to add - */ - move_to(coord) { - this.length++; - this.coords.push(coord); - } -} -exports._LineString = _LineString; -//# sourceMappingURL=line-string.js.map \ No newline at end of file diff --git a/dist/line-string.js.map b/dist/line-string.js.map deleted file mode 100644 index c8de0cb..0000000 --- a/dist/line-string.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"line-string.js","sourceRoot":"","sources":["../src/line-string.ts"],"names":[],"mappings":";;;AAEA;;GAEG;AACH,MAAa,WAAW;IACb,MAAM,GAAe,EAAE,CAAC;IACxB,MAAM,GAAW,CAAC,CAAC;IAE1B;;;;OAIG;IACH,OAAO,CAAC,KAAe;QACnB,IAAI,CAAC,MAAM,EAAE,CAAC;QACd,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAC5B,CAAC;CACJ;AAbD,kCAaC"} \ No newline at end of file diff --git a/dist/types.d.ts b/dist/types.d.ts deleted file mode 100644 index dbb8490..0000000 --- a/dist/types.d.ts +++ /dev/null @@ -1,30 +0,0 @@ -export type { Feature as GeoJSONFeature, LineString, MultiLineString, Position } from 'geojson'; -/** - * Core coordinate interface representing a point with x (longitude) and y (latitude) - */ -export interface CoordinatePoint { - /** Longitude in degrees */ - x: number; - /** Latitude in degrees */ - y: number; -} -/** - * Options for Arc generation - */ -export interface ArcOptions { - /** - * Offset from dateline in degrees (default: 10) - * Controls the likelihood that lines will be split which cross the dateline. - * The higher the number the more likely. Lines within this many degrees - * of the dateline will be split. - */ - offset?: number; -} -/** - * Internal line geometry representation - */ -export interface LineGeometry { - coords: [number, number][]; - length: number; -} -//# sourceMappingURL=types.d.ts.map \ No newline at end of file diff --git a/dist/types.d.ts.map b/dist/types.d.ts.map deleted file mode 100644 index 8257346..0000000 --- a/dist/types.d.ts.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AACA,YAAY,EACV,OAAO,IAAI,cAAc,EACzB,UAAU,EACV,eAAe,EACf,QAAQ,EACT,MAAM,SAAS,CAAC;AAEjB;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,2BAA2B;IAC3B,CAAC,EAAE,MAAM,CAAC;IACV,0BAA0B;IAC1B,CAAC,EAAE,MAAM,CAAC;CACX;AAED;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB;;;;;OAKG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,MAAM,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,CAAC;IAC3B,MAAM,EAAE,MAAM,CAAC;CAChB"} \ No newline at end of file diff --git a/dist/types.js b/dist/types.js deleted file mode 100644 index 11e638d..0000000 --- a/dist/types.js +++ /dev/null @@ -1,3 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -//# sourceMappingURL=types.js.map \ No newline at end of file diff --git a/dist/types.js.map b/dist/types.js.map deleted file mode 100644 index c768b79..0000000 --- a/dist/types.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""} \ No newline at end of file diff --git a/dist/utils.d.ts b/dist/utils.d.ts deleted file mode 100644 index d045269..0000000 --- a/dist/utils.d.ts +++ /dev/null @@ -1,24 +0,0 @@ -import type { Position } from './types.js'; -/** - * Round coordinate decimal values to 6 places for precision - * - * @param coords - A coordinate position (longitude, latitude, optional elevation) - * @returns Rounded coordinate position - * - * @example - * ```typescript - * const coords = [45.123456789, 50.987654321]; - * const roundedCoords = roundCoords(coords); - * console.log(roundedCoords); // [45.123457, 50.987654] - * ``` - */ -export declare function roundCoords(coords: Position): Position; -/** - * Convert degrees to radians - */ -export declare const D2R: number; -/** - * Convert radians to degrees - */ -export declare const R2D: number; -//# sourceMappingURL=utils.d.ts.map \ No newline at end of file diff --git a/dist/utils.d.ts.map b/dist/utils.d.ts.map deleted file mode 100644 index 00fbee9..0000000 --- a/dist/utils.d.ts.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAE3C;;;;;;;;;;;;GAYG;AACH,wBAAgB,WAAW,CAAC,MAAM,EAAE,QAAQ,GAAG,QAAQ,CAiBtD;AAED;;GAEG;AACH,eAAO,MAAM,GAAG,QAAgB,CAAC;AAEjC;;GAEG;AACH,eAAO,MAAM,GAAG,QAAgB,CAAC"} \ No newline at end of file diff --git a/dist/utils.js b/dist/utils.js deleted file mode 100644 index e63fb72..0000000 --- a/dist/utils.js +++ /dev/null @@ -1,40 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.R2D = exports.D2R = void 0; -exports.roundCoords = roundCoords; -/** - * Round coordinate decimal values to 6 places for precision - * - * @param coords - A coordinate position (longitude, latitude, optional elevation) - * @returns Rounded coordinate position - * - * @example - * ```typescript - * const coords = [45.123456789, 50.987654321]; - * const roundedCoords = roundCoords(coords); - * console.log(roundedCoords); // [45.123457, 50.987654] - * ``` - */ -function roundCoords(coords) { - // round coordinate decimal values to 6 places - const PRECISION = 6; - const MULTIPLIER = Math.pow(10, PRECISION); - const rounded = []; - for (let i = 0; i < coords.length; i++) { - const coord = coords[i]; - if (coord !== undefined) { - // https://stackoverflow.com/questions/11832914/how-to-round-to-at-most-2-decimal-places-if-necessary - rounded[i] = Math.round((coord + Number.EPSILON) * MULTIPLIER) / MULTIPLIER; - } - } - return rounded; -} -/** - * Convert degrees to radians - */ -exports.D2R = Math.PI / 180; -/** - * Convert radians to degrees - */ -exports.R2D = 180 / Math.PI; -//# sourceMappingURL=utils.js.map \ No newline at end of file diff --git a/dist/utils.js.map b/dist/utils.js.map deleted file mode 100644 index 1f79516..0000000 --- a/dist/utils.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":";;;AAeA,kCAiBC;AA9BD;;;;;;;;;;;;GAYG;AACH,SAAgB,WAAW,CAAC,MAAgB;IACxC,8CAA8C;IAC9C,MAAM,SAAS,GAAG,CAAC,CAAC;IACpB,MAAM,UAAU,GAAG,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,SAAS,CAAC,CAAC;IAE3C,MAAM,OAAO,GAAa,EAAE,CAAC;IAC7B,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QACrC,MAAM,KAAK,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC;QACxB,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;YACtB,qGAAqG;YACrG,OAAO,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,KAAK,CACnB,CAAC,KAAK,GAAG,MAAM,CAAC,OAAO,CAAC,GAAG,UAAU,CACxC,GAAG,UAAU,CAAC;QACnB,CAAC;IACL,CAAC;IAED,OAAO,OAAO,CAAC;AACnB,CAAC;AAED;;GAEG;AACU,QAAA,GAAG,GAAG,IAAI,CAAC,EAAE,GAAG,GAAG,CAAC;AAEjC;;GAEG;AACU,QAAA,GAAG,GAAG,GAAG,GAAG,IAAI,CAAC,EAAE,CAAC"} \ No newline at end of file From 769c6f830ae2242cebebbae7a82bf805a92ff6e9 Mon Sep 17 00:00:00 2001 From: John Gravois Date: Thu, 26 Mar 2026 20:00:53 -0700 Subject: [PATCH 2/2] chore: advertise Node.js 16x as the minimum supported version --- .github/workflows/tests.yml | 16 ++++++++-------- package.json | 2 +- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 5221ae6..70210a8 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -13,13 +13,13 @@ jobs: strategy: matrix: os: [ubuntu-latest] - node: [16, 18] + node: [16, 18, 20, 22, 24] steps: - - uses: actions/checkout@v5 - - name: Use Node.js ${{ matrix.node }} - uses: actions/setup-node@v6 - with: - node-version: ${{ matrix.node }} - - run: npm i - - run: npm test + - uses: actions/checkout@v6 + - name: Use Node.js ${{ matrix.node }} + uses: actions/setup-node@v6 + with: + node-version: ${{ matrix.node }} + - run: npm ci + - run: npm test diff --git a/package.json b/package.json index 02d60b4..0d12ac9 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,7 @@ "CHANGELOG.md" ], "engines": { - "node": ">=0.4.0" + "node": ">=16.11.0" }, "scripts": { "build": "npm run clean && tsc && tsc -p tsconfig.esm.json && npm run build:browser",