@trackunit/geo-json-utils 1.0.0 → 1.0.2
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/index.cjs.js +17 -4
- package/index.esm.js +17 -5
- package/package.json +1 -1
- package/src/GeoJsonUtils.d.ts +6 -0
package/index.cjs.js
CHANGED
|
@@ -377,13 +377,13 @@ const getExtremeGeoJsonPointFromPolygon = ({ polygon, direction, }) => {
|
|
|
377
377
|
var _a, _b, _c, _d;
|
|
378
378
|
switch (direction) {
|
|
379
379
|
case "top":
|
|
380
|
-
return currentPoint[1] > ((_a = extremePoint === null || extremePoint === void 0 ? void 0 : extremePoint[1]) !== null && _a !== void 0 ? _a : -Infinity) ? currentPoint : extremePoint !== null && extremePoint !== void 0 ? extremePoint : currentPoint;
|
|
380
|
+
return currentPoint[1] > ((_a = extremePoint === null || extremePoint === void 0 ? void 0 : extremePoint[1]) !== null && _a !== void 0 ? _a : -Infinity) ? currentPoint : (extremePoint !== null && extremePoint !== void 0 ? extremePoint : currentPoint);
|
|
381
381
|
case "right":
|
|
382
|
-
return currentPoint[0] > ((_b = extremePoint === null || extremePoint === void 0 ? void 0 : extremePoint[0]) !== null && _b !== void 0 ? _b : -Infinity) ? currentPoint : extremePoint !== null && extremePoint !== void 0 ? extremePoint : currentPoint;
|
|
382
|
+
return currentPoint[0] > ((_b = extremePoint === null || extremePoint === void 0 ? void 0 : extremePoint[0]) !== null && _b !== void 0 ? _b : -Infinity) ? currentPoint : (extremePoint !== null && extremePoint !== void 0 ? extremePoint : currentPoint);
|
|
383
383
|
case "bottom":
|
|
384
|
-
return currentPoint[1] < ((_c = extremePoint === null || extremePoint === void 0 ? void 0 : extremePoint[1]) !== null && _c !== void 0 ? _c : Infinity) ? currentPoint : extremePoint !== null && extremePoint !== void 0 ? extremePoint : currentPoint;
|
|
384
|
+
return currentPoint[1] < ((_c = extremePoint === null || extremePoint === void 0 ? void 0 : extremePoint[1]) !== null && _c !== void 0 ? _c : Infinity) ? currentPoint : (extremePoint !== null && extremePoint !== void 0 ? extremePoint : currentPoint);
|
|
385
385
|
case "left":
|
|
386
|
-
return currentPoint[0] < ((_d = extremePoint === null || extremePoint === void 0 ? void 0 : extremePoint[0]) !== null && _d !== void 0 ? _d : Infinity) ? currentPoint : extremePoint !== null && extremePoint !== void 0 ? extremePoint : currentPoint;
|
|
386
|
+
return currentPoint[0] < ((_d = extremePoint === null || extremePoint === void 0 ? void 0 : extremePoint[0]) !== null && _d !== void 0 ? _d : Infinity) ? currentPoint : (extremePoint !== null && extremePoint !== void 0 ? extremePoint : currentPoint);
|
|
387
387
|
default: {
|
|
388
388
|
throw new Error(`${direction} is not known`);
|
|
389
389
|
}
|
|
@@ -470,6 +470,18 @@ const getGeoJsonPolygonIntersection = (polygon1, polygon2) => {
|
|
|
470
470
|
coordinates: intersectionResult,
|
|
471
471
|
};
|
|
472
472
|
};
|
|
473
|
+
/**
|
|
474
|
+
* @description Creates a TU bounding box from a GeoJSON Bbox.
|
|
475
|
+
* @param bbox The GeoJSON Bbox to create a TU bounding box from
|
|
476
|
+
* @returns {TuBoundingBox} The TU bounding box created from the GeoJSON Bbox
|
|
477
|
+
*/
|
|
478
|
+
const getBoundingBoxFromGeoJsonBbox = (bbox) => {
|
|
479
|
+
const [minLon, minLat, maxLon, maxLat] = bbox;
|
|
480
|
+
return {
|
|
481
|
+
nw: { longitude: minLon, latitude: maxLat },
|
|
482
|
+
se: { longitude: maxLon, latitude: minLat },
|
|
483
|
+
};
|
|
484
|
+
};
|
|
473
485
|
|
|
474
486
|
//! These tools are used to bridge the gap with out poorly typed graphql types
|
|
475
487
|
// Should be ideally be avoided but are needed until we fix the graphql types
|
|
@@ -630,6 +642,7 @@ exports.geoJsonPointSchema = geoJsonPointSchema;
|
|
|
630
642
|
exports.geoJsonPolygonSchema = geoJsonPolygonSchema;
|
|
631
643
|
exports.geoJsonPositionSchema = geoJsonPositionSchema;
|
|
632
644
|
exports.getBboxFromGeoJsonPolygon = getBboxFromGeoJsonPolygon;
|
|
645
|
+
exports.getBoundingBoxFromGeoJsonBbox = getBoundingBoxFromGeoJsonBbox;
|
|
633
646
|
exports.getBoundingBoxFromGeoJsonPolygon = getBoundingBoxFromGeoJsonPolygon;
|
|
634
647
|
exports.getExtremeGeoJsonPointFromPolygon = getExtremeGeoJsonPointFromPolygon;
|
|
635
648
|
exports.getGeoJsonPolygonFromBoundingBox = getGeoJsonPolygonFromBoundingBox;
|
package/index.esm.js
CHANGED
|
@@ -375,13 +375,13 @@ const getExtremeGeoJsonPointFromPolygon = ({ polygon, direction, }) => {
|
|
|
375
375
|
var _a, _b, _c, _d;
|
|
376
376
|
switch (direction) {
|
|
377
377
|
case "top":
|
|
378
|
-
return currentPoint[1] > ((_a = extremePoint === null || extremePoint === void 0 ? void 0 : extremePoint[1]) !== null && _a !== void 0 ? _a : -Infinity) ? currentPoint : extremePoint !== null && extremePoint !== void 0 ? extremePoint : currentPoint;
|
|
378
|
+
return currentPoint[1] > ((_a = extremePoint === null || extremePoint === void 0 ? void 0 : extremePoint[1]) !== null && _a !== void 0 ? _a : -Infinity) ? currentPoint : (extremePoint !== null && extremePoint !== void 0 ? extremePoint : currentPoint);
|
|
379
379
|
case "right":
|
|
380
|
-
return currentPoint[0] > ((_b = extremePoint === null || extremePoint === void 0 ? void 0 : extremePoint[0]) !== null && _b !== void 0 ? _b : -Infinity) ? currentPoint : extremePoint !== null && extremePoint !== void 0 ? extremePoint : currentPoint;
|
|
380
|
+
return currentPoint[0] > ((_b = extremePoint === null || extremePoint === void 0 ? void 0 : extremePoint[0]) !== null && _b !== void 0 ? _b : -Infinity) ? currentPoint : (extremePoint !== null && extremePoint !== void 0 ? extremePoint : currentPoint);
|
|
381
381
|
case "bottom":
|
|
382
|
-
return currentPoint[1] < ((_c = extremePoint === null || extremePoint === void 0 ? void 0 : extremePoint[1]) !== null && _c !== void 0 ? _c : Infinity) ? currentPoint : extremePoint !== null && extremePoint !== void 0 ? extremePoint : currentPoint;
|
|
382
|
+
return currentPoint[1] < ((_c = extremePoint === null || extremePoint === void 0 ? void 0 : extremePoint[1]) !== null && _c !== void 0 ? _c : Infinity) ? currentPoint : (extremePoint !== null && extremePoint !== void 0 ? extremePoint : currentPoint);
|
|
383
383
|
case "left":
|
|
384
|
-
return currentPoint[0] < ((_d = extremePoint === null || extremePoint === void 0 ? void 0 : extremePoint[0]) !== null && _d !== void 0 ? _d : Infinity) ? currentPoint : extremePoint !== null && extremePoint !== void 0 ? extremePoint : currentPoint;
|
|
384
|
+
return currentPoint[0] < ((_d = extremePoint === null || extremePoint === void 0 ? void 0 : extremePoint[0]) !== null && _d !== void 0 ? _d : Infinity) ? currentPoint : (extremePoint !== null && extremePoint !== void 0 ? extremePoint : currentPoint);
|
|
385
385
|
default: {
|
|
386
386
|
throw new Error(`${direction} is not known`);
|
|
387
387
|
}
|
|
@@ -468,6 +468,18 @@ const getGeoJsonPolygonIntersection = (polygon1, polygon2) => {
|
|
|
468
468
|
coordinates: intersectionResult,
|
|
469
469
|
};
|
|
470
470
|
};
|
|
471
|
+
/**
|
|
472
|
+
* @description Creates a TU bounding box from a GeoJSON Bbox.
|
|
473
|
+
* @param bbox The GeoJSON Bbox to create a TU bounding box from
|
|
474
|
+
* @returns {TuBoundingBox} The TU bounding box created from the GeoJSON Bbox
|
|
475
|
+
*/
|
|
476
|
+
const getBoundingBoxFromGeoJsonBbox = (bbox) => {
|
|
477
|
+
const [minLon, minLat, maxLon, maxLat] = bbox;
|
|
478
|
+
return {
|
|
479
|
+
nw: { longitude: minLon, latitude: maxLat },
|
|
480
|
+
se: { longitude: maxLon, latitude: minLat },
|
|
481
|
+
};
|
|
482
|
+
};
|
|
471
483
|
|
|
472
484
|
//! These tools are used to bridge the gap with out poorly typed graphql types
|
|
473
485
|
// Should be ideally be avoided but are needed until we fix the graphql types
|
|
@@ -612,4 +624,4 @@ const tuGeoJsonRectangularBoxPolygonSchema = z
|
|
|
612
624
|
}
|
|
613
625
|
});
|
|
614
626
|
|
|
615
|
-
export { EARTH_RADIUS, boundingBoxCrossesMeridian, checkCrossesMeridian, coordinatesToStandardFormat, denormalizeLongitude, geoJsonBboxSchema, geoJsonGeometrySchema, geoJsonLineStringSchema, geoJsonLinearRingSchema, geoJsonMultiLineStringSchema, geoJsonMultiPointSchema, geoJsonMultiPolygonSchema, geoJsonPointSchema, geoJsonPolygonSchema, geoJsonPositionSchema, getBboxFromGeoJsonPolygon, getBoundingBoxFromGeoJsonPolygon, getExtremeGeoJsonPointFromPolygon, getGeoJsonPolygonFromBoundingBox, getGeoJsonPolygonIntersection, getMinMaxLongitudes, getMultipleCoordinatesFromGeoJsonObject, getPointCoordinateFromGeoJsonObject, getPointCoordinateFromGeoJsonPoint, getPolygonFromBbox, getPolygonFromPointAndRadius, isFullyContainedInGeoJsonPolygon, isGeoJsonPointInPolygon, isGeoJsonPositionInLinearRing, normalizeLongitudes, tuGeoJsonPointRadiusSchema, tuGeoJsonPolygonNoHolesSchema, tuGeoJsonRectangularBoxPolygonSchema };
|
|
627
|
+
export { EARTH_RADIUS, boundingBoxCrossesMeridian, checkCrossesMeridian, coordinatesToStandardFormat, denormalizeLongitude, geoJsonBboxSchema, geoJsonGeometrySchema, geoJsonLineStringSchema, geoJsonLinearRingSchema, geoJsonMultiLineStringSchema, geoJsonMultiPointSchema, geoJsonMultiPolygonSchema, geoJsonPointSchema, geoJsonPolygonSchema, geoJsonPositionSchema, getBboxFromGeoJsonPolygon, getBoundingBoxFromGeoJsonBbox, getBoundingBoxFromGeoJsonPolygon, getExtremeGeoJsonPointFromPolygon, getGeoJsonPolygonFromBoundingBox, getGeoJsonPolygonIntersection, getMinMaxLongitudes, getMultipleCoordinatesFromGeoJsonObject, getPointCoordinateFromGeoJsonObject, getPointCoordinateFromGeoJsonPoint, getPolygonFromBbox, getPolygonFromPointAndRadius, isFullyContainedInGeoJsonPolygon, isGeoJsonPointInPolygon, isGeoJsonPositionInLinearRing, normalizeLongitudes, tuGeoJsonPointRadiusSchema, tuGeoJsonPolygonNoHolesSchema, tuGeoJsonRectangularBoxPolygonSchema };
|
package/package.json
CHANGED
package/src/GeoJsonUtils.d.ts
CHANGED
|
@@ -81,4 +81,10 @@ export declare const isFullyContainedInGeoJsonPolygon: (polygon1: GeoJsonPolygon
|
|
|
81
81
|
* @returns {(GeoJsonMultiPolygon | GeoJsonPolygon)} The intersection as either a Polygon (if one contains the other) or MultiPolygon
|
|
82
82
|
*/
|
|
83
83
|
export declare const getGeoJsonPolygonIntersection: (polygon1: GeoJsonPolygon | GeoJsonMultiPolygon, polygon2: GeoJsonPolygon | GeoJsonMultiPolygon) => GeoJsonMultiPolygon | GeoJsonPolygon | null;
|
|
84
|
+
/**
|
|
85
|
+
* @description Creates a TU bounding box from a GeoJSON Bbox.
|
|
86
|
+
* @param bbox The GeoJSON Bbox to create a TU bounding box from
|
|
87
|
+
* @returns {TuBoundingBox} The TU bounding box created from the GeoJSON Bbox
|
|
88
|
+
*/
|
|
89
|
+
export declare const getBoundingBoxFromGeoJsonBbox: (bbox: GeoJsonBbox) => TuBoundingBox;
|
|
84
90
|
export {};
|