@terascope/geo-utils 2.0.0-dev.7

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.MD ADDED
@@ -0,0 +1,17 @@
1
+ <!-- THIS FILE IS AUTO-GENERATED, EDIT docs/packages/geo-utils/overview.md -->
2
+
3
+ # Geo Utils
4
+
5
+ > A collection of Teraslice Geo Utilities
6
+
7
+ This is a package within the [Teraslice](https://github.com/terascope/teraslice) monorepo. See our [documentation](https://terascope.github.io/teraslice/docs/packages/geo-utils/overview) for more information or the [issues](https://github.com/terascope/teraslice/issues?q=is%3Aopen+is%3Aissue+label%3Apkg%2Fgeo-utils) associated with this package
8
+
9
+ ## Contributing
10
+
11
+ Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
12
+
13
+ Please make sure to update tests as appropriate.
14
+
15
+ ## License
16
+
17
+ [MIT](./LICENSE) licensed.
package/README.md ADDED
@@ -0,0 +1,17 @@
1
+ <!-- THIS FILE IS AUTO-GENERATED, EDIT docs/packages/geo-utils/overview.md -->
2
+
3
+ # Geo Utils
4
+
5
+ > A collection of Teraslice Geo Utilities
6
+
7
+ This is a package within the [Teraslice](https://github.com/terascope/teraslice) monorepo. See our [documentation](https://terascope.github.io/teraslice/docs/packages/geo-utils/overview) for more information or the [issues](https://github.com/terascope/teraslice/issues?q=is%3Aopen+is%3Aissue+label%3Apkg%2Fgeo-utils) associated with this package
8
+
9
+ ## Contributing
10
+
11
+ Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
12
+
13
+ Please make sure to update tests as appropriate.
14
+
15
+ ## License
16
+
17
+ [MIT](./LICENSE) licensed.
@@ -0,0 +1,73 @@
1
+ import { GeoDistanceUnit, GeoPointInput, GeoShape, GeoPoint, GeoDistanceObj, GeoShapePoint, GeoShapePolygon, GeoShapeMultiPolygon, ESGeoShape, CoordinateTuple, GeoShapeRelation, GeoInput } from '@terascope/types';
2
+ import type { MultiPolygon, Feature, GeoJsonProperties, Polygon } from 'geojson';
3
+ import geoHash from 'latlon-geohash';
4
+ export declare const geoJSONTypes: string[];
5
+ export declare function isGeoJSON(input: unknown): input is GeoShape | ESGeoShape;
6
+ export declare function isGeoShapePoint(input: unknown): input is GeoShapePoint;
7
+ export declare function isGeoShapePolygon(input: unknown): input is GeoShapePolygon;
8
+ export declare function isGeoShapeMultiPolygon(input: unknown): input is GeoShapeMultiPolygon;
9
+ export declare function parseGeoDistance(str: string): GeoDistanceObj;
10
+ export declare function parseGeoDistanceUnit(input: string): GeoDistanceUnit;
11
+ /**
12
+ * Convert an input into a Geo Point object with lat and lon
13
+ */
14
+ export declare function parseGeoPoint(point: GeoPointInput | unknown): GeoPoint;
15
+ export declare function parseGeoPoint(point: GeoPointInput | unknown, throwInvalid: true): GeoPoint;
16
+ export declare function parseGeoPoint(point: GeoPointInput | unknown, throwInvalid: false): GeoPoint | null;
17
+ export declare function isGeoPoint(input: unknown): boolean;
18
+ export declare function makeGeoBBox(point1: GeoPoint, point2: GeoPoint): Feature<Polygon, GeoJsonProperties>;
19
+ export declare function inGeoBoundingBox(top_left: GeoPointInput, bottom_right: GeoPointInput, point: GeoPointInput): boolean;
20
+ export declare function inGeoBoundingBoxFP(top_left: GeoPointInput, bottom_right: GeoPointInput): (input: unknown) => boolean;
21
+ export declare function makeCoordinatesFromGeoPoint(point: GeoPoint): CoordinateTuple;
22
+ export declare function geoPolyHasPoint<G extends Polygon | MultiPolygon>(polygon: Feature<G> | G): (fieldData: unknown) => boolean;
23
+ export declare function makeGeoCircle(point: GeoPoint, distance: number, unitVal?: GeoDistanceUnit): Feature<Polygon> | undefined;
24
+ export declare function geoPointWithinRange(startingPoint: GeoPointInput, distanceValue: string, point: GeoPointInput): boolean;
25
+ export declare function geoPointWithinRangeFP(startingPoint: GeoPointInput, distanceValue: string): (input: unknown) => boolean;
26
+ export declare function geoRelationFP(geoShape: GeoInput, relation: GeoShapeRelation): (input: unknown) => boolean;
27
+ /** Converts a geoJSON object to its turf geo feature counterpart */
28
+ export declare function makeGeoFeature(geoShape: unknown): Feature<any> | undefined;
29
+ /** Converts a geoJSON object to its turf geo feature counterpart, will throw if not valid */
30
+ export declare function makeGeoFeatureOrThrow(geoShape: unknown): Feature<any>;
31
+ /**
32
+ * Returns true if the second geometry is completely contained by the first geometry.
33
+ * The interiors of both geometries must intersect and, the interior and boundary of
34
+ * the secondary geometry must not intersect the exterior of the first geometry.
35
+ */
36
+ export declare function geoContains(firstGeoEntity: GeoInput, secondGeoEntity: GeoInput): boolean;
37
+ /**
38
+ * When provided with geoInput that acts as the argument geo-feature, it will return a function
39
+ * that accepts any geoInput and checks to see if the new input contains the argument geo-feature
40
+ */
41
+ export declare function geoContainsFP(queryGeoEntity: GeoInput): (input: unknown) => boolean;
42
+ /**
43
+ * Returns true if the first geometry is completely within the second geometry.
44
+ * The interiors of both geometries must intersect and, the interior and boundary
45
+ * of the first geometry must not intersect the exterior of the second geometry
46
+ */
47
+ export declare function geoWithin(firstGeoEntity: GeoInput, secondGeoEntity: GeoInput): boolean;
48
+ /**
49
+ * When provided with geoInput that acts as the parent geo-feature, it will return a function
50
+ * that accepts any geoInput and checks to see if the new input is within the parent geo-feature
51
+ */
52
+ export declare function geoWithinFP(queryGeoEntity: GeoInput): (input: unknown) => boolean;
53
+ /** Returns true if both geo entities intersect each other, if one of the input geo entity
54
+ * is a point, it will check if the other geo-entity contains the point
55
+ */
56
+ export declare function geoIntersects(firstGeoEntity: GeoInput, secondGeoEntity: GeoInput): boolean;
57
+ export declare function geoIntersectsFP(queryGeoEntity: GeoInput): (input: unknown) => boolean;
58
+ export declare function geoDisjointFP(queryGeoEntity: GeoInput): (input: unknown) => boolean;
59
+ /** Returns true if both geo entities have no overlap */
60
+ export declare function geoDisjoint(firstGeoEntity: GeoInput, secondGeoEntity: GeoInput): boolean;
61
+ /** Only able to convert geo-points to either a geo-json point or a simple polygon.
62
+ * There is no current support for creating polygon with holes or multi-polygon
63
+ * as of right now. geoJSON input is made sure to be properly formatted for its type value
64
+ */
65
+ export declare function toGeoJSON(input: unknown): GeoShape | undefined;
66
+ export declare function toGeoJSONOrThrow(input: unknown): GeoShape;
67
+ export declare function validateListCoords(coords: CoordinateTuple[]): any[];
68
+ export declare function polyHasHoles(input: GeoShape): boolean;
69
+ /** Takes in a geo point like entity and returns the timezone of its location */
70
+ export declare function lookupTimezone(input: unknown): string;
71
+ export declare function tzCacheLoaded(): boolean;
72
+ export { geoHash };
73
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,eAAe,EAEf,aAAa,EACb,QAAQ,EACR,QAAQ,EACR,cAAc,EAGd,aAAa,EACb,eAAe,EACf,oBAAoB,E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@terascope/types';
2
+ import bbox from '@turf/bbox';
3
+ import bboxPolygon from '@turf/bbox-polygon';
4
+ import equal from '@turf/boolean-equal';
5
+ import createCircle from '@turf/circle';
6
+ import pointInPolygon from '@turf/boolean-point-in-polygon';
7
+ import within from '@turf/boolean-within';
8
+ import contains from '@turf/boolean-contains';
9
+ import disjoint from '@turf/boolean-disjoint';
10
+ import intersect from '@turf/boolean-intersects';
11
+ import { lineString, multiPolygon, polygon as tPolygon, point as tPoint, } from '@turf/helpers';
12
+ import lineToPolygon from '@turf/line-to-polygon';
13
+ import { getCoords } from '@turf/invariant';
14
+ import { find as geoToTimezone, setCache } from 'geo-tz';
15
+ import geoHash from 'latlon-geohash';
16
+ import { isArrayLike, isPlainObject, getTypeOf, trim, toString, parseNumberList, toNumber, isNumber, isKey } from '@terascope/core-utils';
17
+ export const geoJSONTypes = Object.keys(GeoShapeType).map((key) => key.toLowerCase());
18
+ // allows for better access and control over tz-geo cache
19
+ const TZ_GEO_CACHE = new Map();
20
+ export function isGeoJSON(input) {
21
+ if (!isPlainObject(input))
22
+ return false;
23
+ if (!isArrayLike(input.coordinates))
24
+ return false;
25
+ const type = input.type;
26
+ if (typeof type !== 'string')
27
+ return false;
28
+ return geoJSONTypes.includes(type.toLowerCase());
29
+ }
30
+ export function isGeoShapePoint(input) {
31
+ return isGeoJSON(input)
32
+ && (input.type === GeoShapeType.Point || input.type === ESGeoShapeType.Point);
33
+ }
34
+ export function isGeoShapePolygon(input) {
35
+ return isGeoJSON(input)
36
+ && (input.type === GeoShapeType.Polygon || input.type === ESGeoShapeType.Polygon);
37
+ }
38
+ export function isGeoShapeMultiPolygon(input) {
39
+ return isGeoJSON(input)
40
+ && (input.type === GeoShapeType.MultiPolygon || input.type === ESGeoShapeType.MultiPolygon);
41
+ }
42
+ export function parseGeoDistance(str) {
43
+ const matches = trim(str).match(/(\d+)(.*)$/);
44
+ if (!matches || !matches.length) {
45
+ throw new TypeError(`Incorrect geo distance parameter provided: ${str}`);
46
+ }
47
+ const distance = Number(matches[1]);
48
+ const unit = parseGeoDistanceUnit(matches[2]);
49
+ return { distance, unit };
50
+ }
51
+ export function parseGeoDistanceUnit(input) {
52
+ const unit = GEO_DISTANCE_UNITS[trim(input)];
53
+ if (!unit) {
54
+ throw new TypeError(`Incorrect distance unit provided: ${input}`);
55
+ }
56
+ return unit;
57
+ }
58
+ function getLonAndLat(input, throwInvalid = true) {
59
+ if (!isPlainObject(input)) {
60
+ if (!throwInvalid)
61
+ return null;
62
+ throw new TypeError(`Invalid geo point, expected object, got ${input} (${getTypeOf(input)})`);
63
+ }
64
+ const obj = input;
65
+ let lat;
66
+ let lon;
67
+ if ('lat' in obj && 'lon' in obj) {
68
+ if (isNumber(obj.lat) && isNumber(obj.lon)) {
69
+ return obj;
70
+ }
71
+ lat = obj.lat;
72
+ lon = obj.lon;
73
+ }
74
+ else if ('latitude' in obj && 'longitude' in obj) {
75
+ lat = obj.latitude;
76
+ lon = obj.longitude;
77
+ }
78
+ else if (isGeoShapePoint(obj)) {
79
+ [lon, lat] = obj.coordinates;
80
+ }
81
+ if (throwInvalid && (lat == null || lon == null)) {
82
+ if (isGeoShapePolygon(obj) || isGeoShapeMultiPolygon(obj)) {
83
+ throw new TypeError([
84
+ `Expected a Point geo shape, received a geo ${obj.type} shape,`,
85
+ 'you may need to switch to a polygon compatible operation'
86
+ ].join(' '));
87
+ }
88
+ throw new TypeError('Invalid geo point object, it must contain keys lat,lon or latitude/longitude');
89
+ }
90
+ lat = toNumber(lat);
91
+ lon = toNumber(lon);
92
+ if (!isNumber(lat) || !isNumber(lon)) {
93
+ if (throwInvalid) {
94
+ throw new TypeError('Invalid geo point, lat and lon must be numbers');
95
+ }
96
+ return null;
97
+ }
98
+ return { lat, lon };
99
+ }
100
+ export function parseGeoPoint(point, throwInvalid = true) {
101
+ let lat;
102
+ let lon;
103
+ if (typeof point === 'string') {
104
+ if (point.includes(',')) {
105
+ [lat, lon] = parseNumberList(point);
106
+ }
107
+ else {
108
+ try {
109
+ return geoHash.decode(point);
110
+ }
111
+ catch (err) {
112
+ // do nothing
113
+ }
114
+ }
115
+ }
116
+ else if (isPlainObject(point)) {
117
+ const results = getLonAndLat(point, throwInvalid);
118
+ if (results)
119
+ return results;
120
+ }
121
+ else if (isArrayLike(point)) {
122
+ // array of points are meant to be lon/lat format
123
+ [lon, lat] = parseNumberList(point);
124
+ }
125
+ if (throwInvalid && (lat == null || lon == null)) {
126
+ throw new TypeError(`Invalid geo point given to parse, got ${point} (${getTypeOf(point)})`);
127
+ }
128
+ // data incoming is lat,lon and we must return lon,lat
129
+ if (lat != null && lon != null) {
130
+ return {
131
+ lat,
132
+ lon
133
+ };
134
+ }
135
+ return null;
136
+ }
137
+ export function isGeoPoint(input) {
138
+ return parseGeoPoint(input, false) != null;
139
+ }
140
+ export function makeGeoBBox(point1, point2) {
141
+ const line = lineString([
142
+ makeCoordinatesFromGeoPoint(point1),
143
+ makeCoordinatesFromGeoPoint(point2)
144
+ ]);
145
+ const box = bbox(line);
146
+ return bboxPolygon(box);
147
+ }
148
+ export function inGeoBoundingBox(top_left, bottom_right, point) {
149
+ const topLeft = parseGeoPoint(top_left);
150
+ const bottomRight = parseGeoPoint(bottom_right);
151
+ const polygon = makeGeoBBox(topLeft, bottomRight);
152
+ if (polygon == null) {
153
+ throw new Error(`Invalid bounding box created from topLeft: ${topLeft}, bottomRight: ${bottomRight}`);
154
+ }
155
+ return geoPolyHasPoint(polygon)(point);
156
+ }
157
+ export function inGeoBoundingBoxFP(top_left, bottom_right) {
158
+ const topLeft = parseGeoPoint(top_left);
159
+ const bottomRight = parseGeoPoint(bottom_right);
160
+ const polygon = makeGeoBBox(topLeft, bottomRight);
161
+ if (polygon == null) {
162
+ throw new Error(`Invalid bounding box created from topLeft: ${topLeft}, bottomRight: ${bottomRight}`);
163
+ }
164
+ return geoPolyHasPoint(polygon);
165
+ }
166
+ export function makeCoordinatesFromGeoPoint(point) {
167
+ return [point.lon, point.lat];
168
+ }
169
+ export function geoPolyHasPoint(polygon) {
170
+ return (fieldData) => {
171
+ const point = parseGeoPoint(fieldData, false);
172
+ if (!point)
173
+ return false;
174
+ return pointInPolygon(makeCoordinatesFromGeoPoint(point), polygon);
175
+ };
176
+ }
177
+ export function makeGeoCircle(point, distance, unitVal) {
178
+ // There is a mismatch between elasticsearch and turf on "inch" naming
179
+ const units = unitVal === 'inch' ? 'inches' : unitVal;
180
+ return createCircle(makeCoordinatesFromGeoPoint(point), distance, { units });
181
+ }
182
+ export function geoPointWithinRange(startingPoint, distanceValue, point) {
183
+ const sPoint = parseGeoPoint(startingPoint);
184
+ const { distance, unit } = parseGeoDistance(distanceValue);
185
+ const polygon = makeGeoCircle(sPoint, distance, unit);
186
+ if (polygon == null) {
187
+ throw new Error(`Invalid startingPoint: ${startingPoint}`);
188
+ }
189
+ return geoPolyHasPoint(polygon)(point);
190
+ }
191
+ export function geoPointWithinRangeFP(startingPoint, distanceValue) {
192
+ const sPoint = parseGeoPoint(startingPoint);
193
+ const { distance, unit } = parseGeoDistance(distanceValue);
194
+ const polygon = makeGeoCircle(sPoint, distance, unit);
195
+ if (polygon == null) {
196
+ throw new Error(`Invalid startingPoint: ${startingPoint}`);
197
+ }
198
+ return geoPolyHasPoint(polygon);
199
+ }
200
+ export function geoRelationFP(geoShape, relation) {
201
+ if (relation === GeoShapeRelation.Within) {
202
+ return geoWithinFP(geoShape);
203
+ }
204
+ if (relation === GeoShapeRelation.Contains) {
205
+ return geoContainsFP(geoShape);
206
+ }
207
+ if (relation === GeoShapeRelation.Intersects) {
208
+ return geoIntersectsFP(geoShape);
209
+ }
210
+ if (relation === GeoShapeRelation.Disjoint) {
211
+ return geoDisjointFP(geoShape);
212
+ }
213
+ throw new Error(`Unsupported relation ${relation}`);
214
+ }
215
+ /** Converts a geoJSON object to its turf geo feature counterpart */
216
+ export function makeGeoFeature(geoShape) {
217
+ if (isGeoShapePoint(geoShape)) {
218
+ return tPoint(geoShape.coordinates);
219
+ }
220
+ if (isGeoShapeMultiPolygon(geoShape)) {
221
+ return multiPolygon(geoShape.coordinates);
222
+ }
223
+ if (isGeoShapePolygon(geoShape)) {
224
+ return tPolygon(geoShape.coordinates);
225
+ }
226
+ return;
227
+ }
228
+ /** Converts a geoJSON object to its turf geo feature counterpart, will throw if not valid */
229
+ export function makeGeoFeatureOrThrow(geoShape) {
230
+ const results = makeGeoFeature(geoShape);
231
+ if (!results) {
232
+ throw new Error(`Invalid input: ${JSON.stringify(geoShape)}, is not a valid geo-shape`);
233
+ }
234
+ return results;
235
+ }
236
+ /**
237
+ * Returns true if the second geometry is completely contained by the first geometry.
238
+ * The interiors of both geometries must intersect and, the interior and boundary of
239
+ * the secondary geometry must not intersect the exterior of the first geometry.
240
+ */
241
+ export function geoContains(firstGeoEntity, secondGeoEntity) {
242
+ return geoContainsFP(secondGeoEntity)(firstGeoEntity);
243
+ }
244
+ /**
245
+ * When provided with geoInput that acts as the argument geo-feature, it will return a function
246
+ * that accepts any geoInput and checks to see if the new input contains the argument geo-feature
247
+ */
248
+ export function geoContainsFP(queryGeoEntity) {
249
+ const queryGeo = toGeoJSONOrThrow(queryGeoEntity);
250
+ const queryFeature = makeGeoFeatureOrThrow(queryGeo);
251
+ if (isGeoShapePoint(queryGeo))
252
+ return _pointContains(queryFeature);
253
+ const { polygons: queryPolygons, holes: queryHoles } = _featureToPolygonAndHoles(queryFeature);
254
+ return function _geoContains(input) {
255
+ const inputGeoEntity = toGeoJSON(input);
256
+ if (!inputGeoEntity)
257
+ return false;
258
+ if (isGeoPoint(inputGeoEntity)) {
259
+ // point cannot contain a poly like feature
260
+ return false;
261
+ }
262
+ const inputFeature = makeGeoFeature(inputGeoEntity);
263
+ if (!inputFeature)
264
+ return false;
265
+ const { polygons: inputPolygons, holes: inputHoles } = _featureToPolygonAndHoles(inputFeature);
266
+ if (inputHoles.length) {
267
+ const withinInputHole = inputHoles.some((iHolePoly) => queryPolygons.some((qPoly) => intersect(qPoly, iHolePoly)));
268
+ if (withinInputHole) {
269
+ // check to see if holes are the same, if so they don't overlap
270
+ if (queryHoles.length) {
271
+ return queryHoles.some((qHole) => inputHoles.some((iHole) => equal(qHole, iHole)));
272
+ }
273
+ return false;
274
+ }
275
+ }
276
+ return queryPolygons.every((qPoly) => inputPolygons.some((iPoly) => contains(iPoly, qPoly)));
277
+ };
278
+ }
279
+ function _pointContains(queryFeature) {
280
+ return (input) => {
281
+ const inputGeoEntity = toGeoJSON(input);
282
+ if (!inputGeoEntity)
283
+ return false;
284
+ const inputFeature = makeGeoFeature(inputGeoEntity);
285
+ if (!inputFeature)
286
+ return false;
287
+ if (isGeoPoint(inputGeoEntity)) {
288
+ return equal(inputFeature, queryFeature);
289
+ }
290
+ const { polygons, holes } = _featureToPolygonAndHoles(inputFeature);
291
+ let pointInHole = false;
292
+ if (holes.length) {
293
+ pointInHole = holes.some((iPolyHole) => contains(iPolyHole, queryFeature));
294
+ }
295
+ return !pointInHole && polygons.some((poly) => contains(poly, queryFeature));
296
+ };
297
+ }
298
+ function _featureToPolygonAndHoles(inputFeature) {
299
+ const inputHoles = [];
300
+ const inputCoords = getCoords(inputFeature);
301
+ let inputPolygons;
302
+ if (inputFeature.geometry.type === 'MultiPolygon') {
303
+ inputPolygons = inputCoords
304
+ .map((coords) => {
305
+ if (coords.length > 1) {
306
+ const [polygon, ...holes] = coords.map((innerCords) => tPolygon([innerCords]));
307
+ inputHoles.push(...holes);
308
+ return polygon;
309
+ }
310
+ return tPolygon(coords);
311
+ });
312
+ }
313
+ else if (inputFeature.geometry.type === 'Polygon') {
314
+ const [polyCoords, ...holeCords] = inputCoords;
315
+ inputPolygons = [tPolygon([polyCoords])];
316
+ const holePolygons = holeCords.map((coords) => tPolygon([coords]));
317
+ inputHoles.push(...holePolygons);
318
+ }
319
+ else {
320
+ throw new Error(`Cannot convert ${toString(inputFeature)} to a polygon`);
321
+ }
322
+ return { holes: inputHoles, polygons: inputPolygons };
323
+ }
324
+ function _pointToPointMatch(queryInput) {
325
+ return (input) => {
326
+ const inputGeoEntity = toGeoJSON(input);
327
+ if (!inputGeoEntity)
328
+ return false;
329
+ if (!isGeoShapePoint(inputGeoEntity))
330
+ return false;
331
+ const inputFeature = makeGeoFeature(inputGeoEntity);
332
+ if (!inputFeature)
333
+ return false;
334
+ return equal(queryInput, inputFeature);
335
+ };
336
+ }
337
+ /**
338
+ * Returns true if the first geometry is completely within the second geometry.
339
+ * The interiors of both geometries must intersect and, the interior and boundary
340
+ * of the first geometry must not intersect the exterior of the second geometry
341
+ */
342
+ export function geoWithin(firstGeoEntity, secondGeoEntity) {
343
+ return geoWithinFP(secondGeoEntity)(firstGeoEntity);
344
+ }
345
+ /**
346
+ * When provided with geoInput that acts as the parent geo-feature, it will return a function
347
+ * that accepts any geoInput and checks to see if the new input is within the parent geo-feature
348
+ */
349
+ export function geoWithinFP(queryGeoEntity) {
350
+ const queryGeo = toGeoJSONOrThrow(queryGeoEntity);
351
+ const queryFeature = makeGeoFeatureOrThrow(queryGeo);
352
+ // point can only be compared to other points
353
+ if (isGeoShapePoint(queryGeo))
354
+ return _pointToPointMatch(queryFeature);
355
+ const { polygons: queryPolygons, holes: queryHoles } = _featureToPolygonAndHoles(queryFeature);
356
+ const hasQueryHoles = queryHoles.length > 0;
357
+ return function _geoWithinFP(input) {
358
+ const inputGeoEntity = toGeoJSON(input);
359
+ if (!inputGeoEntity)
360
+ return false;
361
+ const inputFeature = makeGeoFeature(inputGeoEntity);
362
+ if (!inputFeature)
363
+ return false;
364
+ if (isGeoShapePoint(inputGeoEntity)) {
365
+ if (hasQueryHoles) {
366
+ const withinQueryHole = queryHoles
367
+ .some((holeFeature) => intersect(inputFeature, holeFeature));
368
+ if (withinQueryHole)
369
+ return false;
370
+ }
371
+ return queryPolygons.some(within.bind(within, inputFeature));
372
+ }
373
+ const { polygons: inputPolygons, holes: inputHoles } = _featureToPolygonAndHoles(inputFeature);
374
+ if (hasQueryHoles) {
375
+ // holes intersect main body
376
+ const withinQueryHole = queryHoles.some((qHole) => {
377
+ const bool = intersect(inputFeature, qHole);
378
+ if (bool && inputHoles.length) {
379
+ // if they are equal, then don't immediately falsify
380
+ const inner = !inputHoles.some((inputHole) => equal(qHole, inputHole));
381
+ return inner;
382
+ }
383
+ return bool;
384
+ });
385
+ if (withinQueryHole)
386
+ return false;
387
+ }
388
+ return inputPolygons.every((iPoly) => queryPolygons.some(within.bind(within, iPoly)));
389
+ };
390
+ }
391
+ /** Returns true if both geo entities intersect each other, if one of the input geo entity
392
+ * is a point, it will check if the other geo-entity contains the point
393
+ */
394
+ export function geoIntersects(firstGeoEntity, secondGeoEntity) {
395
+ return geoIntersectsFP(firstGeoEntity)(secondGeoEntity);
396
+ }
397
+ export function geoIntersectsFP(queryGeoEntity) {
398
+ const queryGeo = toGeoJSONOrThrow(queryGeoEntity);
399
+ const queryFeature = makeGeoFeatureOrThrow(queryGeo);
400
+ return function _geoIntersectsFP(input) {
401
+ const inputGeoEntity = toGeoJSON(input);
402
+ if (!inputGeoEntity)
403
+ return false;
404
+ const inputFeature = makeGeoFeature(inputGeoEntity);
405
+ if (!inputFeature)
406
+ return false;
407
+ return intersect(inputFeature, queryFeature);
408
+ };
409
+ }
410
+ export function geoDisjointFP(queryGeoEntity) {
411
+ const queryGeo = toGeoJSONOrThrow(queryGeoEntity);
412
+ const queryFeature = makeGeoFeatureOrThrow(queryGeo);
413
+ return function _geoDisjointFP(input) {
414
+ const inputGeoEntity = toGeoJSON(input);
415
+ if (!inputGeoEntity)
416
+ return false;
417
+ const inputFeature = makeGeoFeature(inputGeoEntity);
418
+ if (!inputFeature)
419
+ return false;
420
+ return disjoint(inputFeature, queryFeature);
421
+ };
422
+ }
423
+ /** Returns true if both geo entities have no overlap */
424
+ export function geoDisjoint(firstGeoEntity, secondGeoEntity) {
425
+ return geoDisjointFP(firstGeoEntity)(secondGeoEntity);
426
+ }
427
+ const esTypeMap = {
428
+ [ESGeoShapeType.Point]: GeoShapeType.Point,
429
+ [ESGeoShapeType.MultiPolygon]: GeoShapeType.MultiPolygon,
430
+ [ESGeoShapeType.Polygon]: GeoShapeType.Polygon,
431
+ };
432
+ /** Only able to convert geo-points to either a geo-json point or a simple polygon.
433
+ * There is no current support for creating polygon with holes or multi-polygon
434
+ * as of right now. geoJSON input is made sure to be properly formatted for its type value
435
+ */
436
+ export function toGeoJSON(input) {
437
+ if (isGeoJSON(input)) {
438
+ const { type: inputType } = input;
439
+ const type = isKey(esTypeMap, inputType) ? esTypeMap[inputType] : inputType;
440
+ return { ...input, type };
441
+ }
442
+ if (isGeoPoint(input)) {
443
+ const coordinates = makeCoordinatesFromGeoPoint(parseGeoPoint(input));
444
+ return {
445
+ type: GeoShapeType.Point,
446
+ coordinates
447
+ };
448
+ }
449
+ if (Array.isArray(input)) {
450
+ try {
451
+ const points = input.map((point) => makeCoordinatesFromGeoPoint(parseGeoPoint(point)));
452
+ const coordinates = validateListCoords(points);
453
+ return {
454
+ type: GeoShapeType.Polygon,
455
+ coordinates
456
+ };
457
+ }
458
+ catch (_err) {
459
+ // ignore here
460
+ }
461
+ }
462
+ }
463
+ export function toGeoJSONOrThrow(input) {
464
+ const geoJSON = toGeoJSON(input);
465
+ if (!geoJSON) {
466
+ throw new Error(`Cannot convert ${JSON.stringify(input)} to valid geoJSON`);
467
+ }
468
+ return geoJSON;
469
+ }
470
+ export function validateListCoords(coords) {
471
+ if (coords.length < 3) {
472
+ throw new Error('Points parameter for a geoPolygon query must have at least three geo-points');
473
+ }
474
+ const line = lineString(coords);
475
+ const polygon = lineToPolygon(line);
476
+ // @ts-expect-error
477
+ return getCoords(polygon);
478
+ }
479
+ export function polyHasHoles(input) {
480
+ if (isGeoShapePolygon(input)) {
481
+ return input.coordinates.length > 1;
482
+ }
483
+ if (isGeoShapeMultiPolygon(input)) {
484
+ return input.coordinates[0].length > 1;
485
+ }
486
+ return false;
487
+ }
488
+ /** Takes in a geo point like entity and returns the timezone of its location */
489
+ export function lookupTimezone(input) {
490
+ if (!tzCacheLoaded()) {
491
+ setCache({ preload: true, store: TZ_GEO_CACHE });
492
+ }
493
+ const { lat, lon } = parseGeoPoint(input);
494
+ // it returns an array, return the first one
495
+ return geoToTimezone(lat, lon)[0];
496
+ }
497
+ export function tzCacheLoaded() {
498
+ return TZ_GEO_CACHE.size > 0;
499
+ }
500
+ // TODO: maybe move this to data-mate as this is a directive only function
501
+ // export function toTimeZoneUsingLocation(val: unknown, location: unknown) {
502
+ // // location validation happens inside lookupTimezone
503
+ // const timezone = lookupTimezone(location);
504
+ // return toTimeZone(val, timezone);
505
+ // }
506
+ // export function toTimeZoneUsingLocationFP(location: unknown) {
507
+ // // location validation happens inside lookupTimezone
508
+ // const timezone = lookupTimezone(location);
509
+ // return function _toTimeZoneUsingLocation(val: unknown) {
510
+ // return toTimeZone(val, timezone);
511
+ // };
512
+ // }
513
+ export { geoHash };
514
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAEH,kBAAkB,EAKlB,YAAY,EACZ,cAAc,EAMd,gBAAgB,EAEnB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,IAAI,MAAM,YAAY,CAAC;AAC9B,OAAO,WAAW,MAAM,oBAAoB,CAAC;AAC7C,OAAO,KAAK,MAAM,qBAAqB,CAAC;AACxC,OAAO,YAAY,MAAM,cAAc,CAAC;AACxC,OAAO,cAAc,MAAM,gCAAgC,CAAC;AAC5D,OAAO,MAAM,MAAM,sBAAsB,CAAC;AAC1C,OAAO,QAAQ,MAAM,wBAAwB,CAAC;AAC9C,OAAO,QAAQ,MAAM,wBAAwB,CAAC;AAC9C,OAAO,SAAS,MAAM,0BAA0B,CAAC;AACjD,OAAO,EACH,UAAU,EACV,YAAY,EACZ,OAAO,IAAI,QAAQ,EACnB,KAAK,IAAI,MAAM,GAClB,MAAM,eAAe,CAAC;AAQvB,OAAO,aAAa,MAAM,uBAAuB,CAAC;AAClD,OAAO,EAAE,SAAS,EAAE,MAAM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nB,OAAO,SAAS,CAAC,OAAO,CAAC,CAAC;AAC9B,CAAC;AAED,MAAM,UAAU,YAAY,CAAC,KAAe;IACxC,IAAI,iBAAiB,CAAC,KAAK,CAAC,EAAE,CAAC;QAC3B,OAAO,KAAK,CAAC,WAAW,CAAC,MAAM,GAAG,CAAC,CAAC;IACxC,CAAC;IAED,IAAI,sBAAsB,CAAC,KAAK,CAAC,EAAE,CAAC;QAChC,OAAO,KAAK,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC;IAC3C,CAAC;IAED,OAAO,KAAK,CAAC;AACjB,CAAC;AAED,gFAAgF;AAChF,MAAM,UAAU,cAAc,CAAC,KAAc;IACzC,IAAI,CAAC,aAAa,EAAE,EAAE,CAAC;QACnB,QAAQ,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,YAAY,EAAE,CAAC,CAAC;IACrD,CAAC;IAED,MAAM,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,aAAa,CAAC,KAAsB,CAAC,CAAC;IAC3D,4CAA4C;IAC5C,OAAO,aAAa,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;AACtC,CAAC;AAED,MAAM,UAAU,aAAa;IACzB,OAAO,YAAY,CAAC,IAAI,GAAG,CAAC,CAAC;AACjC,CAAC;AAED,0EAA0E;AAC1E,6EAA6E;AAC7E,2DAA2D;AAC3D,iDAAiD;AACjD,wCAAwC;AACxC,IAAI;AAEJ,iEAAiE;AACjE,2DAA2D;AAC3D,iDAAiD;AAEjD,+DAA+D;AAC/D,4CAA4C;AAC5C,SAAS;AACT,IAAI;AAEJ,OAAO,EACH,OAAO,EACV,CAAC"}
package/package.json ADDED
@@ -0,0 +1,61 @@
1
+ {
2
+ "name": "@terascope/geo-utils",
3
+ "displayName": "Geo Utils",
4
+ "version": "2.0.0-dev.7",
5
+ "description": "A collection of Teraslice Geo Utilities",
6
+ "homepage": "https://github.com/terascope/teraslice/tree/master/packages/geo-utils#readme",
7
+ "bugs": {
8
+ "url": "https://github.com/terascope/teraslice/issues"
9
+ },
10
+ "repository": "git@github.com:terascope/teraslice.git",
11
+ "license": "MIT",
12
+ "author": "Terascope, LLC <info@terascope.io>",
13
+ "sideEffects": false,
14
+ "type": "module",
15
+ "main": "dist/src/index.js",
16
+ "typings": "dist/src/index.d.ts",
17
+ "files": [
18
+ "dist/src/**/*"
19
+ ],
20
+ "scripts": {
21
+ "build": "tsc --build",
22
+ "build:watch": "yarn build --watch",
23
+ "test": "node ../scripts/bin/ts-scripts test ../geo-utils --",
24
+ "test:debug": "node ../scripts/bin/ts-scripts test --debug ../geo-utils --",
25
+ "test:watch": "node ../scripts/bin/ts-scripts test --watch ../geo-utils --"
26
+ },
27
+ "dependencies": {
28
+ "@terascope/core-utils": "~2.0.0-dev.7",
29
+ "@terascope/types": "~2.0.0-dev.6",
30
+ "@turf/bbox": "~7.2.0",
31
+ "@turf/bbox-polygon": "~7.2.0",
32
+ "@turf/boolean-contains": "~7.2.0",
33
+ "@turf/boolean-disjoint": "~7.2.0",
34
+ "@turf/boolean-equal": "~7.2.0",
35
+ "@turf/boolean-intersects": "~7.2.0",
36
+ "@turf/boolean-point-in-polygon": "~7.2.0",
37
+ "@turf/boolean-within": "~7.2.0",
38
+ "@turf/circle": "~7.2.0",
39
+ "@turf/helpers": "~7.2.0",
40
+ "@turf/invariant": "~7.2.0",
41
+ "@turf/line-to-polygon": "~7.2.0",
42
+ "geo-tz": "~8.1.4",
43
+ "latlon-geohash": "~2.0.0"
44
+ },
45
+ "devDependencies": {
46
+ "@types/geojson": "~7946.0.16"
47
+ },
48
+ "engines": {
49
+ "node": ">=22.0.0",
50
+ "yarn": ">=1.22.19"
51
+ },
52
+ "publishConfig": {
53
+ "access": "public",
54
+ "registry": "https://registry.npmjs.org/"
55
+ },
56
+ "srcMain": "src/index.ts",
57
+ "terascope": {
58
+ "enableTypedoc": true,
59
+ "testSuite": "unit"
60
+ }
61
+ }