@carto/api-client 0.4.6-0 → 0.4.6

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.
Files changed (81) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/build/api-client.cjs +208 -2167
  3. package/build/api-client.cjs.map +1 -1
  4. package/build/api-client.modern.js +208 -2040
  5. package/build/api-client.modern.js.map +1 -1
  6. package/build/constants.d.ts +0 -22
  7. package/build/index.d.ts +1 -4
  8. package/build/models/index.d.ts +1 -1
  9. package/build/sources/h3-tileset-source.d.ts +1 -2
  10. package/build/sources/index.d.ts +1 -1
  11. package/build/sources/quadbin-tileset-source.d.ts +1 -2
  12. package/build/sources/vector-tileset-source.d.ts +1 -2
  13. package/build/spatial-index.d.ts +7 -1
  14. package/build/types-internal.d.ts +0 -4
  15. package/build/types.d.ts +1 -61
  16. package/build/widget-sources/index.d.ts +1 -3
  17. package/build/widget-sources/types.d.ts +22 -31
  18. package/build/widget-sources/{widget-source.d.ts → widget-base-source.d.ts} +38 -13
  19. package/build/widget-sources/widget-query-source.d.ts +2 -2
  20. package/build/widget-sources/widget-table-source.d.ts +2 -2
  21. package/package.json +11 -14
  22. package/src/constants.ts +0 -25
  23. package/src/index.ts +1 -5
  24. package/src/models/index.ts +1 -1
  25. package/src/sources/h3-tileset-source.ts +6 -18
  26. package/src/sources/index.ts +1 -1
  27. package/src/sources/quadbin-tileset-source.ts +6 -18
  28. package/src/sources/raster-source.ts +0 -1
  29. package/src/sources/vector-query-source.ts +2 -5
  30. package/src/sources/vector-table-source.ts +2 -5
  31. package/src/sources/vector-tileset-source.ts +6 -19
  32. package/src/spatial-index.ts +8 -5
  33. package/src/types-internal.ts +0 -6
  34. package/src/types.ts +2 -60
  35. package/src/widget-sources/index.ts +1 -3
  36. package/src/widget-sources/types.ts +22 -32
  37. package/src/widget-sources/{widget-remote-source.ts → widget-base-source.ts} +147 -12
  38. package/src/widget-sources/widget-query-source.ts +3 -6
  39. package/src/widget-sources/widget-table-source.ts +3 -6
  40. package/build/filters/Filter.d.ts +0 -13
  41. package/build/filters/FilterTypes.d.ts +0 -3
  42. package/build/filters/geosjonFeatures.d.ts +0 -8
  43. package/build/filters/index.d.ts +0 -6
  44. package/build/filters/tileFeatures.d.ts +0 -20
  45. package/build/filters/tileFeaturesGeometries.d.ts +0 -13
  46. package/build/filters/tileFeaturesSpatialIndex.d.ts +0 -10
  47. package/build/operations/aggregation.d.ts +0 -8
  48. package/build/operations/applySorting.d.ts +0 -20
  49. package/build/operations/groupBy.d.ts +0 -15
  50. package/build/operations/groupByDate.d.ts +0 -11
  51. package/build/operations/histogram.d.ts +0 -13
  52. package/build/operations/index.d.ts +0 -6
  53. package/build/operations/scatterPlot.d.ts +0 -14
  54. package/build/utils/dateUtils.d.ts +0 -10
  55. package/build/utils/getTileFormat.d.ts +0 -3
  56. package/build/utils/makeIntervalComplete.d.ts +0 -2
  57. package/build/utils/transformTileCoordsToWGS84.d.ts +0 -8
  58. package/build/utils/transformToTileCoords.d.ts +0 -9
  59. package/build/widget-sources/widget-remote-source.d.ts +0 -18
  60. package/build/widget-sources/widget-tileset-source.d.ts +0 -76
  61. package/src/filters/Filter.ts +0 -169
  62. package/src/filters/FilterTypes.ts +0 -109
  63. package/src/filters/geosjonFeatures.ts +0 -32
  64. package/src/filters/index.ts +0 -6
  65. package/src/filters/tileFeatures.ts +0 -56
  66. package/src/filters/tileFeaturesGeometries.ts +0 -444
  67. package/src/filters/tileFeaturesSpatialIndex.ts +0 -119
  68. package/src/operations/aggregation.ts +0 -154
  69. package/src/operations/applySorting.ts +0 -109
  70. package/src/operations/groupBy.ts +0 -59
  71. package/src/operations/groupByDate.ts +0 -98
  72. package/src/operations/histogram.ts +0 -66
  73. package/src/operations/index.ts +0 -6
  74. package/src/operations/scatterPlot.ts +0 -50
  75. package/src/utils/dateUtils.ts +0 -28
  76. package/src/utils/getTileFormat.ts +0 -9
  77. package/src/utils/makeIntervalComplete.ts +0 -17
  78. package/src/utils/transformTileCoordsToWGS84.ts +0 -77
  79. package/src/utils/transformToTileCoords.ts +0 -85
  80. package/src/widget-sources/widget-source.ts +0 -160
  81. package/src/widget-sources/widget-tileset-source.ts +0 -407
@@ -1,56 +0,0 @@
1
- import {SpatialFilter, SpatialIndexTile, Tile} from '../types';
2
- import {tileFeaturesGeometries} from './tileFeaturesGeometries';
3
- import {tileFeaturesSpatialIndex} from './tileFeaturesSpatialIndex';
4
- import {SpatialIndex, TileFormat} from '../constants';
5
- import {DEFAULT_GEO_COLUMN} from '../constants-internal';
6
- import {FeatureData} from '../types-internal';
7
- import {SpatialDataType} from '../sources/types';
8
-
9
- /** @internalRemarks Source: @carto/react-core */
10
- export type TileFeatures = {
11
- tiles: Tile[];
12
- tileFormat: TileFormat;
13
- spatialDataType: SpatialDataType;
14
- spatialDataColumn?: string;
15
- spatialFilter?: SpatialFilter;
16
- uniqueIdProperty?: string;
17
- options?: TileFeatureExtractOptions;
18
- };
19
-
20
- /** @internalRemarks Source: @carto/react-core */
21
- export type TileFeatureExtractOptions = {
22
- storeGeometry?: boolean;
23
- };
24
-
25
- /** @internalRemarks Source: @carto/react-core */
26
- export function tileFeatures({
27
- tiles,
28
- spatialFilter,
29
- uniqueIdProperty,
30
- tileFormat,
31
- spatialDataColumn = DEFAULT_GEO_COLUMN,
32
- spatialDataType,
33
- options = {},
34
- }: TileFeatures): FeatureData[] {
35
- // TODO(cleanup): Is an empty response the expected result when spatialFilter
36
- // is omitted? Why not make the parameter required, or return the full input?
37
- if (!spatialFilter) {
38
- return [];
39
- }
40
-
41
- if (spatialDataType !== 'geo') {
42
- return tileFeaturesSpatialIndex({
43
- tiles: tiles as SpatialIndexTile[],
44
- spatialFilter,
45
- spatialDataColumn,
46
- spatialDataType,
47
- });
48
- }
49
- return tileFeaturesGeometries({
50
- tiles,
51
- tileFormat,
52
- spatialFilter,
53
- uniqueIdProperty,
54
- options,
55
- });
56
- }
@@ -1,444 +0,0 @@
1
- import bboxPolygon from '@turf/bbox-polygon';
2
- import intersects from '@turf/boolean-intersects';
3
- import booleanWithin from '@turf/boolean-within';
4
- import intersect from '@turf/intersect';
5
- import {transformToTileCoords} from '../utils/transformToTileCoords.js';
6
- import {transformTileCoordsToWGS84} from '../utils/transformTileCoordsToWGS84.js';
7
- import {TileFormat} from '../constants.js';
8
- import {
9
- BBox,
10
- Feature,
11
- Geometry,
12
- LineString,
13
- MultiPolygon,
14
- Point,
15
- Polygon,
16
- Position,
17
- } from 'geojson';
18
- import {SpatialFilter, Tile} from '../types.js';
19
- import {TileFeatureExtractOptions} from './tileFeatures.js';
20
- import {featureCollection} from '@turf/helpers';
21
- import {FeatureData} from '../types-internal.js';
22
- import {
23
- BinaryAttribute,
24
- BinaryFeature,
25
- BinaryGeometryType,
26
- BinaryPointFeature,
27
- TypedArrayConstructor,
28
- } from '@loaders.gl/schema';
29
-
30
- export const FEATURE_GEOM_PROPERTY = '__geomValue';
31
-
32
- type TileMap = Map<unknown, unknown>;
33
-
34
- type TileDataInternal = {
35
- uniqueId: string | number | undefined;
36
- properties: any;
37
- numericProps: Record<string, number>;
38
- };
39
-
40
- export function tileFeaturesGeometries({
41
- tiles,
42
- tileFormat,
43
- spatialFilter,
44
- uniqueIdProperty,
45
- options,
46
- }: {
47
- tiles: Tile[];
48
- tileFormat?: TileFormat;
49
- spatialFilter: SpatialFilter;
50
- uniqueIdProperty?: string;
51
- options?: {storeGeometry?: boolean};
52
- }): FeatureData[] {
53
- const map = new Map();
54
-
55
- for (const tile of tiles) {
56
- // Discard if it's not a visible tile (only check false value, not undefined)
57
- // or tile has not data
58
- if (tile.isVisible === false || !tile.data) {
59
- continue;
60
- }
61
-
62
- const bbox = [
63
- tile.bbox.west,
64
- tile.bbox.south,
65
- tile.bbox.east,
66
- tile.bbox.north,
67
- ] as BBox;
68
- const bboxToGeom = bboxPolygon(bbox);
69
- const tileIsFullyVisible = booleanWithin(bboxToGeom, spatialFilter);
70
-
71
- // Clip the geometry to intersect with the tile
72
- const spatialFilterFeature: Feature<Polygon | MultiPolygon> = {
73
- type: 'Feature',
74
- geometry: spatialFilter,
75
- properties: {},
76
- };
77
- const clippedGeometryToIntersect = intersect(
78
- featureCollection([bboxToGeom, spatialFilterFeature])
79
- );
80
-
81
- if (!clippedGeometryToIntersect) {
82
- continue;
83
- }
84
-
85
- // We assume that MVT tileFormat uses local coordinates so we transform the geometry to intersect to tile coordinates [0..1],
86
- // while in the case of 'geojson' or binary, the geometries are already in WGS84
87
- const transformedGeometryToIntersect =
88
- tileFormat === TileFormat.MVT
89
- ? transformToTileCoords(clippedGeometryToIntersect.geometry, bbox)
90
- : clippedGeometryToIntersect.geometry;
91
-
92
- createIndicesForPoints(tile.data.points!);
93
-
94
- calculateFeatures({
95
- map,
96
- tileIsFullyVisible,
97
- geometryIntersection: transformedGeometryToIntersect,
98
- data: tile.data.points!,
99
- type: 'Point',
100
- bbox,
101
- tileFormat,
102
- uniqueIdProperty,
103
- options,
104
- });
105
- calculateFeatures({
106
- map,
107
- tileIsFullyVisible,
108
- geometryIntersection: transformedGeometryToIntersect,
109
- data: tile.data.lines!,
110
- type: 'LineString',
111
- bbox,
112
- tileFormat,
113
- uniqueIdProperty,
114
- options,
115
- });
116
- calculateFeatures({
117
- map,
118
- tileIsFullyVisible,
119
- geometryIntersection: transformedGeometryToIntersect,
120
- data: tile.data.polygons!,
121
- type: 'Polygon',
122
- bbox,
123
- tileFormat,
124
- uniqueIdProperty,
125
- options,
126
- });
127
- }
128
- return Array.from(map.values());
129
- }
130
-
131
- function processTileFeatureProperties({
132
- map,
133
- data,
134
- startIndex,
135
- endIndex,
136
- type,
137
- bbox,
138
- tileFormat,
139
- uniqueIdProperty,
140
- storeGeometry,
141
- geometryIntersection,
142
- }: {
143
- map: TileMap;
144
- data: BinaryFeature;
145
- startIndex: number;
146
- endIndex: number;
147
- type: BinaryGeometryType;
148
- bbox: BBox;
149
- tileFormat?: TileFormat;
150
- uniqueIdProperty?: string;
151
- storeGeometry: boolean;
152
- geometryIntersection?: Geometry;
153
- }) {
154
- const tileProps = getPropertiesFromTile(data, startIndex);
155
- const uniquePropertyValue = getUniquePropertyValue(
156
- tileProps,
157
- uniqueIdProperty,
158
- map
159
- );
160
-
161
- if (!uniquePropertyValue || map.has(uniquePropertyValue)) {
162
- return;
163
- }
164
- let geometry: Geometry | null = null;
165
-
166
- // Only calculate geometry if necessary
167
- if (storeGeometry || geometryIntersection) {
168
- const {positions} = data;
169
- const ringCoordinates = getRingCoordinatesFor(
170
- startIndex,
171
- endIndex,
172
- positions
173
- );
174
- geometry = getFeatureByType(ringCoordinates, type);
175
- }
176
-
177
- // If intersection is required, check before proceeding
178
- if (
179
- geometry &&
180
- geometryIntersection &&
181
- !intersects(geometry, geometryIntersection)
182
- ) {
183
- return;
184
- }
185
-
186
- const properties = parseProperties(tileProps);
187
-
188
- // Only save geometry if necessary
189
- if (storeGeometry && geometry) {
190
- properties[FEATURE_GEOM_PROPERTY] =
191
- tileFormat === TileFormat.MVT
192
- ? transformTileCoordsToWGS84(geometry, bbox)
193
- : geometry;
194
- }
195
- map.set(uniquePropertyValue, properties);
196
- }
197
-
198
- function addIntersectedFeaturesInTile({
199
- map,
200
- data,
201
- geometryIntersection,
202
- type,
203
- bbox,
204
- tileFormat,
205
- uniqueIdProperty,
206
- options,
207
- }: {
208
- map: TileMap;
209
- data: BinaryFeature;
210
- geometryIntersection: Geometry;
211
- type: BinaryGeometryType;
212
- bbox: BBox;
213
- tileFormat?: TileFormat;
214
- uniqueIdProperty?: string;
215
- options?: TileFeatureExtractOptions;
216
- }) {
217
- const indices = getIndices(data);
218
- const storeGeometry = options?.storeGeometry || false;
219
-
220
- for (let i = 0; i < indices.length - 1; i++) {
221
- const startIndex = indices[i];
222
- const endIndex = indices[i + 1];
223
- processTileFeatureProperties({
224
- map,
225
- data,
226
- startIndex,
227
- endIndex,
228
- type,
229
- bbox,
230
- tileFormat,
231
- uniqueIdProperty,
232
- storeGeometry,
233
- geometryIntersection,
234
- });
235
- }
236
- }
237
-
238
- function getIndices(data: BinaryFeature) {
239
- let indices: BinaryAttribute;
240
- switch (data.type) {
241
- case 'Point':
242
- // @ts-expect-error Missing or changed types?
243
- indices = data.pointIndices;
244
- break;
245
- case 'LineString':
246
- indices = data.pathIndices;
247
- break;
248
- case 'Polygon':
249
- indices = data.primitivePolygonIndices;
250
- break;
251
- default:
252
- throw new Error(`Unexpected type, "${(data as BinaryFeature).type}"`);
253
- }
254
- return indices.value;
255
- }
256
-
257
- function getFeatureId(data: BinaryFeature, startIndex: number) {
258
- return data.featureIds.value[startIndex];
259
- }
260
-
261
- function getPropertiesFromTile(data: BinaryFeature, startIndex: number) {
262
- const featureId = getFeatureId(data, startIndex);
263
- const {properties, numericProps, fields} = data;
264
- const result: TileDataInternal = {
265
- uniqueId: (fields?.[featureId] as {id: string | number})?.id,
266
- properties: properties[featureId],
267
- numericProps: {},
268
- };
269
-
270
- for (const key in numericProps) {
271
- result.numericProps[key] = numericProps[key].value[startIndex];
272
- }
273
-
274
- return result;
275
- }
276
-
277
- function parseProperties(tileProps: TileDataInternal) {
278
- const {properties, numericProps} = tileProps;
279
- return Object.assign({}, properties, numericProps);
280
- }
281
-
282
- function getUniquePropertyValue(
283
- tileProps: TileDataInternal,
284
- uniqueIdProperty: string | undefined,
285
- map: TileMap
286
- ) {
287
- if (uniqueIdProperty) {
288
- return getValueFromTileProps(tileProps, uniqueIdProperty);
289
- }
290
-
291
- if (tileProps.uniqueId) {
292
- return tileProps.uniqueId;
293
- }
294
-
295
- const artificialId = map.size + 1; // a counter, assumed as a valid new id
296
- return (
297
- getValueFromTileProps(tileProps, 'cartodb_id') ||
298
- getValueFromTileProps(tileProps, 'geoid') ||
299
- artificialId
300
- );
301
- }
302
-
303
- function getValueFromTileProps(
304
- tileProps: TileDataInternal,
305
- propertyName: string
306
- ) {
307
- const {properties, numericProps} = tileProps;
308
- return numericProps[propertyName] || properties[propertyName];
309
- }
310
-
311
- function getFeatureByType(
312
- coordinates: Position[],
313
- type: BinaryGeometryType
314
- ): Polygon | LineString | Point {
315
- switch (type) {
316
- case 'Polygon':
317
- return {type: 'Polygon', coordinates: [coordinates]};
318
- case 'LineString':
319
- return {type: 'LineString', coordinates};
320
- case 'Point':
321
- return {type: 'Point', coordinates: coordinates[0]};
322
- default:
323
- throw new Error('Invalid geometry type');
324
- }
325
- }
326
-
327
- function getRingCoordinatesFor(
328
- startIndex: number,
329
- endIndex: number,
330
- positions: BinaryAttribute
331
- ) {
332
- const ringCoordinates = [];
333
-
334
- for (let j = startIndex; j < endIndex; j++) {
335
- ringCoordinates.push(
336
- Array.from(
337
- positions.value.subarray(j * positions.size, (j + 1) * positions.size)
338
- )
339
- );
340
- }
341
-
342
- return ringCoordinates;
343
- }
344
-
345
- function calculateFeatures({
346
- map,
347
- tileIsFullyVisible,
348
- geometryIntersection,
349
- data,
350
- type,
351
- bbox,
352
- tileFormat,
353
- uniqueIdProperty,
354
- options,
355
- }: {
356
- map: TileMap;
357
- tileIsFullyVisible: boolean;
358
- geometryIntersection: SpatialFilter;
359
- data: BinaryFeature;
360
- type: BinaryGeometryType;
361
- bbox: BBox;
362
- tileFormat?: TileFormat;
363
- uniqueIdProperty?: string;
364
- options?: TileFeatureExtractOptions;
365
- }) {
366
- if (!data?.properties.length) {
367
- return;
368
- }
369
-
370
- if (tileIsFullyVisible) {
371
- addAllFeaturesInTile({
372
- map,
373
- data,
374
- type,
375
- bbox,
376
- tileFormat,
377
- uniqueIdProperty,
378
- options,
379
- });
380
- } else {
381
- addIntersectedFeaturesInTile({
382
- map,
383
- data,
384
- geometryIntersection,
385
- type,
386
- bbox,
387
- tileFormat,
388
- uniqueIdProperty,
389
- options,
390
- });
391
- }
392
- }
393
-
394
- function addAllFeaturesInTile({
395
- map,
396
- data,
397
- type,
398
- bbox,
399
- tileFormat,
400
- uniqueIdProperty,
401
- options,
402
- }: {
403
- map: TileMap;
404
- data: BinaryFeature;
405
- type: BinaryGeometryType;
406
- bbox: BBox;
407
- tileFormat?: TileFormat;
408
- uniqueIdProperty?: string;
409
- options?: TileFeatureExtractOptions;
410
- }) {
411
- const indices = getIndices(data);
412
- const storeGeometry = options?.storeGeometry || false;
413
- for (let i = 0; i < indices.length - 1; i++) {
414
- const startIndex = indices[i];
415
- const endIndex = indices[i + 1];
416
- processTileFeatureProperties({
417
- map,
418
- data,
419
- startIndex,
420
- endIndex,
421
- type,
422
- bbox,
423
- tileFormat,
424
- uniqueIdProperty,
425
- storeGeometry,
426
- });
427
- }
428
- }
429
-
430
- function createIndicesForPoints(data: BinaryPointFeature) {
431
- const featureIds = data.featureIds.value;
432
- const lastFeatureId = featureIds[featureIds.length - 1];
433
- const PointIndicesArray = featureIds.constructor as TypedArrayConstructor;
434
-
435
- const pointIndices: BinaryAttribute = {
436
- value: new PointIndicesArray(featureIds.length + 1),
437
- size: 1,
438
- };
439
- pointIndices.value.set(featureIds);
440
- pointIndices.value.set([lastFeatureId + 1], featureIds.length);
441
-
442
- // @ts-expect-error Missing or changed types?
443
- data.pointIndices = pointIndices;
444
- }
@@ -1,119 +0,0 @@
1
- import {SpatialIndex} from '../constants.js';
2
- import {getResolution as quadbinGetResolution, geometryToCells} from 'quadbin';
3
- import bboxClip from '@turf/bbox-clip';
4
- import {SpatialFilter, SpatialIndexTile} from '../types.js';
5
- import {BBox, Feature} from 'geojson';
6
- import {getResolution as h3GetResolution, polygonToCells} from 'h3-js';
7
- import {FeatureData} from '../types-internal.js';
8
- import {SpatialDataType} from '../sources/types.js';
9
-
10
- export type TileFeaturesSpatialIndexOptions = {
11
- tiles: SpatialIndexTile[];
12
- spatialFilter: SpatialFilter;
13
- spatialDataColumn: string;
14
- spatialDataType: SpatialDataType;
15
- };
16
-
17
- export function tileFeaturesSpatialIndex({
18
- tiles,
19
- spatialFilter,
20
- spatialDataColumn,
21
- spatialDataType,
22
- }: TileFeaturesSpatialIndexOptions): FeatureData[] {
23
- const map = new Map();
24
- const spatialIndex = getSpatialIndex(spatialDataType);
25
- const resolution = getResolution(tiles, spatialIndex);
26
- const spatialIndexIDName = spatialDataColumn
27
- ? spatialDataColumn
28
- : spatialIndex;
29
-
30
- if (!resolution) {
31
- return [];
32
- }
33
- const cells = getCellsCoverGeometry(spatialFilter, spatialIndex, resolution);
34
-
35
- if (!cells?.length) {
36
- return [];
37
- }
38
-
39
- // We transform cells to Set to improve the performace
40
- const cellsSet = new Set<bigint | string>(cells);
41
-
42
- for (const tile of tiles) {
43
- if (tile.isVisible === false || !tile.data) {
44
- continue;
45
- }
46
-
47
- tile.data.forEach((d: Feature) => {
48
- if (cellsSet.has(d.id as bigint | string)) {
49
- map.set(d.id, {...d.properties, [spatialIndexIDName]: d.id});
50
- }
51
- });
52
- }
53
- return Array.from(map.values());
54
- }
55
-
56
- function getResolution(
57
- tiles: SpatialIndexTile[],
58
- spatialIndex: SpatialIndex
59
- ): number | undefined {
60
- const data = tiles.find((tile) => tile.data?.length)?.data;
61
-
62
- if (!data) {
63
- return;
64
- }
65
-
66
- if (spatialIndex === SpatialIndex.QUADBIN) {
67
- return Number(quadbinGetResolution(data[0].id));
68
- }
69
-
70
- if (spatialIndex === SpatialIndex.H3) {
71
- return h3GetResolution(data[0].id);
72
- }
73
- }
74
-
75
- const bboxWest: BBox = [-180, -90, 0, 90];
76
- const bboxEast: BBox = [0, -90, 180, 90];
77
-
78
- function getCellsCoverGeometry(
79
- geometry: SpatialFilter,
80
- spatialIndex: SpatialIndex,
81
- resolution: number
82
- ) {
83
- if (spatialIndex === SpatialIndex.QUADBIN) {
84
- // @ts-expect-error TODO: Probably ought to be stricter about number vs. bigint types in this file.
85
- return geometryToCells(geometry, resolution);
86
- }
87
-
88
- if (spatialIndex === SpatialIndex.H3) {
89
- // The current H3 polyfill algorithm can't deal with polygon segments of greater than 180 degrees longitude
90
- // so we clip the geometry to be sure that none of them is greater than 180 degrees
91
- // https://github.com/uber/h3-js/issues/24#issuecomment-431893796
92
- return polygonToCells(
93
- bboxClip(geometry, bboxWest).geometry.coordinates as
94
- | number[][]
95
- | number[][][],
96
- resolution,
97
- true
98
- ).concat(
99
- polygonToCells(
100
- bboxClip(geometry, bboxEast).geometry.coordinates as
101
- | number[][]
102
- | number[][][],
103
- resolution,
104
- true
105
- )
106
- );
107
- }
108
- }
109
-
110
- function getSpatialIndex(spatialDataType: SpatialDataType): SpatialIndex {
111
- switch (spatialDataType) {
112
- case 'h3':
113
- return SpatialIndex.H3;
114
- case 'quadbin':
115
- return SpatialIndex.QUADBIN;
116
- default:
117
- throw new Error('Unexpected spatial data type');
118
- }
119
- }