@openforis/arena-core 2.18.4 → 2.18.5
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.
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import turfDestination from '@turf/destination';
|
|
2
2
|
import { DEFAULT_SRS_INDEX } from '../../srs';
|
|
3
|
+
import { Numbers } from '../../utils';
|
|
3
4
|
import { PointFactory } from '../pointFactory';
|
|
4
5
|
import { toLatLong } from './toLatLong';
|
|
5
6
|
import { transform } from './transform';
|
|
@@ -27,7 +28,8 @@ export const pointAtDistance = ({ origin, distanceMeters, bearingDeg, srsIndex =
|
|
|
27
28
|
}
|
|
28
29
|
const target = turfDestination([originLatLong.x, originLatLong.y], distanceMeters, bearingDeg, { units: 'meters' });
|
|
29
30
|
const targetPointLatLong = PointFactory.createInstance({
|
|
30
|
-
|
|
31
|
+
// turf does not wrap the longitude: normalize it into [-180, 180) (e.g. 180.008 => -179.992)
|
|
32
|
+
x: Numbers.absMod(360)(target.geometry.coordinates[0] + 180) - 180,
|
|
31
33
|
y: target.geometry.coordinates[1],
|
|
32
34
|
});
|
|
33
35
|
return transform(targetPointLatLong, origin.srs, srsIndex);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pointAtDistance.js","sourceRoot":"","sources":["../../../../src/geo/points/pointAtDistance.ts"],"names":[],"mappings":"AAAA,OAAO,eAAe,MAAM,mBAAmB,CAAA;AAE/C,OAAO,EAAE,iBAAiB,EAAY,MAAM,WAAW,CAAA;
|
|
1
|
+
{"version":3,"file":"pointAtDistance.js","sourceRoot":"","sources":["../../../../src/geo/points/pointAtDistance.ts"],"names":[],"mappings":"AAAA,OAAO,eAAe,MAAM,mBAAmB,CAAA;AAE/C,OAAO,EAAE,iBAAiB,EAAY,MAAM,WAAW,CAAA;AACvD,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAA;AAErC,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA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EAAE,QAAQ,CAAC,CAAA;AAC5D,CAAC,CAAA","sourcesContent":["import turfDestination from '@turf/destination'\n\nimport { DEFAULT_SRS_INDEX, SRSIndex } from '../../srs'\nimport { Numbers } from '../../utils'\nimport { Point } from '../point'\nimport { PointFactory } from '../pointFactory'\nimport { toLatLong } from './toLatLong'\nimport { transform } from './transform'\nimport { isValid } from './isValid'\n\n/**\n * Takes a point, a distance in meters, and a bearing in degrees, and returns the location of the point at the specified distance and bearing from the original point.\n * @param params\n * @param params.origin - The original point from which to calculate the new location.\n * @param params.distanceMeters - The distance in meters from the original point to the new location.\n * @param params.bearingDeg - The bearing in degrees from the original point to the new location.\n * @param params.srsIndex - SRSs indexed by SRS code.\n * @returns The new point at the specified distance and bearing from the original point, or null if the calculation fails.\n */\nexport const pointAtDistance = ({\n origin,\n distanceMeters,\n bearingDeg,\n srsIndex = DEFAULT_SRS_INDEX,\n}: {\n origin: Point\n distanceMeters: number\n bearingDeg: number\n srsIndex?: SRSIndex\n}): Point | null => {\n const originLatLong = toLatLong(origin, srsIndex)\n\n // Validate numeric inputs and lat/long bounds before calling turfDestination\n if (!originLatLong || !isValid(originLatLong, srsIndex)) {\n return null\n }\n if (!Number.isFinite(distanceMeters) || distanceMeters < 0) {\n return null\n }\n if (!Number.isFinite(bearingDeg)) {\n return null\n }\n const target = turfDestination([originLatLong.x, originLatLong.y], distanceMeters, bearingDeg, { units: 'meters' })\n const targetPointLatLong = PointFactory.createInstance({\n // turf does not wrap the longitude: normalize it into [-180, 180) (e.g. 180.008 => -179.992)\n x: Numbers.absMod(360)(target.geometry.coordinates[0] + 180) - 180,\n y: target.geometry.coordinates[1],\n })\n return transform(targetPointLatLong, origin.srs, srsIndex)\n}\n"]}
|
|
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.pointAtDistance = void 0;
|
|
7
7
|
const destination_1 = __importDefault(require("@turf/destination"));
|
|
8
8
|
const srs_1 = require("../../srs");
|
|
9
|
+
const utils_1 = require("../../utils");
|
|
9
10
|
const pointFactory_1 = require("../pointFactory");
|
|
10
11
|
const toLatLong_1 = require("./toLatLong");
|
|
11
12
|
const transform_1 = require("./transform");
|
|
@@ -33,7 +34,8 @@ const pointAtDistance = ({ origin, distanceMeters, bearingDeg, srsIndex = srs_1.
|
|
|
33
34
|
}
|
|
34
35
|
const target = (0, destination_1.default)([originLatLong.x, originLatLong.y], distanceMeters, bearingDeg, { units: 'meters' });
|
|
35
36
|
const targetPointLatLong = pointFactory_1.PointFactory.createInstance({
|
|
36
|
-
|
|
37
|
+
// turf does not wrap the longitude: normalize it into [-180, 180) (e.g. 180.008 => -179.992)
|
|
38
|
+
x: utils_1.Numbers.absMod(360)(target.geometry.coordinates[0] + 180) - 180,
|
|
37
39
|
y: target.geometry.coordinates[1],
|
|
38
40
|
});
|
|
39
41
|
return (0, transform_1.transform)(targetPointLatLong, origin.srs, srsIndex);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pointAtDistance.js","sourceRoot":"","sources":["../../../src/geo/points/pointAtDistance.ts"],"names":[],"mappings":";;;;;;AAAA,oEAA+C;AAE/C,mCAAuD;
|
|
1
|
+
{"version":3,"file":"pointAtDistance.js","sourceRoot":"","sources":["../../../src/geo/points/pointAtDistance.ts"],"names":[],"mappings":";;;;;;AAAA,oEAA+C;AAE/C,mCAAuD;AACvD,uCAAqC;AAErC,kDAA8C;AAC9C,2CAAuC;AACvC,2CAAuC;AACvC,uCAAmC;AAEnC;;;;;;;;GAQG;AACI,MAAM,eAAe,GAAG,CAAC,EAC9B,MAAM,EACN,cAAc,EACd,UAAU,EACV,QAAQ,GAAG,uBAAiB,GAM7B,EAAgB,EAAE;IACjB,MAAM,aAAa,GAAG,IAAA,qBAAS,EAAC,MAAM,EAAE,QAAQ,CAAC,CAAA;IAEjD,6EAA6E;IAC7E,IAAI,CAAC,aAAa,IAAI,CAAC,IAAA,iBAAO,EAAC,aAAa,EAAE,QAAQ,CAAC,EAAE,CAAC;QACxD,OAAO,IAAI,CAAA;IACb,CAAC;IACD,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,cAAc,CAAC,IAAI,cAAc,GAAG,CAAC,EAAE,CAAC;QAC3D,OAAO,IAAI,CAAA;IACb,CAAC;IACD,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,UAAU,CAAC,EAAE,CAAC;QACjC,OAAO,IAAI,CAAA;IACb,CAAC;IACD,MAAM,MAAM,GAAG,IAAA,qBAAe,EAAC,CAAC,aAAa,CAAC,CAAC,EAAE,aAAa,CAAC,CAAC,CAAC,EAAE,cAAc,EAAE,UAAU,EAAE,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC,CAAA;IACnH,MAAM,kBAAkB,GAAG,2BAAY,CAAC,cAAc,CAAC;QACrD,6FAA6F;QAC7F,CAAC,EAAE,eAAO,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC,GAAG,GAAG;QAClE,CAAC,EAAE,MAAM,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC,CAAC;KAClC,CAAC,CAAA;IACF,OAAO,IAAA,qBAAS,EAAC,kBAAkB,EAAE,MAAM,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAA;AAC5D,CAAC,CAAA;AA9BY,QAAA,eAAe,GAAf,eAAe,CA8B3B","sourcesContent":["import turfDestination from '@turf/destination'\n\nimport { DEFAULT_SRS_INDEX, SRSIndex } from '../../srs'\nimport { Numbers } from '../../utils'\nimport { Point } from '../point'\nimport { PointFactory } from '../pointFactory'\nimport { toLatLong } from './toLatLong'\nimport { transform } from './transform'\nimport { isValid } from './isValid'\n\n/**\n * Takes a point, a distance in meters, and a bearing in degrees, and returns the location of the point at the specified distance and bearing from the original point.\n * @param params\n * @param params.origin - The original point from which to calculate the new location.\n * @param params.distanceMeters - The distance in meters from the original point to the new location.\n * @param params.bearingDeg - The bearing in degrees from the original point to the new location.\n * @param params.srsIndex - SRSs indexed by SRS code.\n * @returns The new point at the specified distance and bearing from the original point, or null if the calculation fails.\n */\nexport const pointAtDistance = ({\n origin,\n distanceMeters,\n bearingDeg,\n srsIndex = DEFAULT_SRS_INDEX,\n}: {\n origin: Point\n distanceMeters: number\n bearingDeg: number\n srsIndex?: SRSIndex\n}): Point | null => {\n const originLatLong = toLatLong(origin, srsIndex)\n\n // Validate numeric inputs and lat/long bounds before calling turfDestination\n if (!originLatLong || !isValid(originLatLong, srsIndex)) {\n return null\n }\n if (!Number.isFinite(distanceMeters) || distanceMeters < 0) {\n return null\n }\n if (!Number.isFinite(bearingDeg)) {\n return null\n }\n const target = turfDestination([originLatLong.x, originLatLong.y], distanceMeters, bearingDeg, { units: 'meters' })\n const targetPointLatLong = PointFactory.createInstance({\n // turf does not wrap the longitude: normalize it into [-180, 180) (e.g. 180.008 => -179.992)\n x: Numbers.absMod(360)(target.geometry.coordinates[0] + 180) - 180,\n y: target.geometry.coordinates[1],\n })\n return transform(targetPointLatLong, origin.srs, srsIndex)\n}\n"]}
|