@carto/api-client 0.5.6 → 0.5.7-alpha-optional-spatial-filter.0
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/build/api-client.cjs +462 -345
- package/build/api-client.cjs.map +1 -1
- package/build/api-client.d.cts +23 -5
- package/build/api-client.d.ts +23 -5
- package/build/api-client.js +426 -309
- package/build/api-client.js.map +1 -1
- package/build/worker-compat.js +4214 -2963
- package/build/worker-compat.js.map +1 -1
- package/build/worker.js +395 -335
- package/build/worker.js.map +1 -1
- package/package.json +2 -2
- package/src/filters/tileFeatures.ts +1 -1
- package/src/filters/tileFeaturesGeometries.ts +28 -55
- package/src/filters/tileFeaturesRaster.ts +16 -12
- package/src/filters/tileFeaturesSpatialIndex.ts +37 -52
- package/src/filters/tileIntersection.ts +158 -0
- package/src/index.ts +1 -0
- package/src/utils/CellSet.ts +90 -0
- package/src/widget-sources/widget-tileset-source-impl.ts +8 -4
package/build/worker.js
CHANGED
|
@@ -1505,6 +1505,110 @@ function geojsonFeatures({
|
|
|
1505
1505
|
return Array.from(map.values());
|
|
1506
1506
|
}
|
|
1507
1507
|
|
|
1508
|
+
// node_modules/@math.gl/core/dist/lib/common.js
|
|
1509
|
+
var RADIANS_TO_DEGREES = 1 / Math.PI * 180;
|
|
1510
|
+
var DEGREES_TO_RADIANS = 1 / 180 * Math.PI;
|
|
1511
|
+
var DEFAULT_CONFIG = {
|
|
1512
|
+
EPSILON: 1e-12,
|
|
1513
|
+
debug: false,
|
|
1514
|
+
precision: 4,
|
|
1515
|
+
printTypes: false,
|
|
1516
|
+
printDegrees: false,
|
|
1517
|
+
printRowMajor: true,
|
|
1518
|
+
_cartographicRadians: false
|
|
1519
|
+
};
|
|
1520
|
+
globalThis.mathgl = globalThis.mathgl || { config: { ...DEFAULT_CONFIG } };
|
|
1521
|
+
var config = globalThis.mathgl.config;
|
|
1522
|
+
function isArray(value) {
|
|
1523
|
+
return Array.isArray(value) || ArrayBuffer.isView(value) && !(value instanceof DataView);
|
|
1524
|
+
}
|
|
1525
|
+
function lerp(a, b, t) {
|
|
1526
|
+
if (isArray(a)) {
|
|
1527
|
+
return a.map((ai, i) => lerp(ai, b[i], t));
|
|
1528
|
+
}
|
|
1529
|
+
return t * b + (1 - t) * a;
|
|
1530
|
+
}
|
|
1531
|
+
|
|
1532
|
+
// node_modules/@math.gl/web-mercator/dist/assert.js
|
|
1533
|
+
function assert2(condition, message) {
|
|
1534
|
+
if (!condition) {
|
|
1535
|
+
throw new Error(message || "@math.gl/web-mercator: assertion failed.");
|
|
1536
|
+
}
|
|
1537
|
+
}
|
|
1538
|
+
|
|
1539
|
+
// node_modules/@math.gl/web-mercator/dist/web-mercator-utils.js
|
|
1540
|
+
var PI = Math.PI;
|
|
1541
|
+
var PI_4 = PI / 4;
|
|
1542
|
+
var DEGREES_TO_RADIANS2 = PI / 180;
|
|
1543
|
+
var RADIANS_TO_DEGREES2 = 180 / PI;
|
|
1544
|
+
var TILE_SIZE = 512;
|
|
1545
|
+
function lngLatToWorld(lngLat) {
|
|
1546
|
+
const [lng, lat] = lngLat;
|
|
1547
|
+
assert2(Number.isFinite(lng));
|
|
1548
|
+
assert2(Number.isFinite(lat) && lat >= -90 && lat <= 90, "invalid latitude");
|
|
1549
|
+
const lambda2 = lng * DEGREES_TO_RADIANS2;
|
|
1550
|
+
const phi2 = lat * DEGREES_TO_RADIANS2;
|
|
1551
|
+
const x = TILE_SIZE * (lambda2 + PI) / (2 * PI);
|
|
1552
|
+
const y = TILE_SIZE * (PI + Math.log(Math.tan(PI_4 + phi2 * 0.5))) / (2 * PI);
|
|
1553
|
+
return [x, y];
|
|
1554
|
+
}
|
|
1555
|
+
function worldToLngLat(xy) {
|
|
1556
|
+
const [x, y] = xy;
|
|
1557
|
+
const lambda2 = x / TILE_SIZE * (2 * PI) - PI;
|
|
1558
|
+
const phi2 = 2 * (Math.atan(Math.exp(y / TILE_SIZE * (2 * PI) - PI)) - PI_4);
|
|
1559
|
+
return [lambda2 * RADIANS_TO_DEGREES2, phi2 * RADIANS_TO_DEGREES2];
|
|
1560
|
+
}
|
|
1561
|
+
|
|
1562
|
+
// node_modules/@math.gl/web-mercator/dist/get-bounds.js
|
|
1563
|
+
var DEGREES_TO_RADIANS3 = Math.PI / 180;
|
|
1564
|
+
|
|
1565
|
+
// src/utils/transformTileCoordsToWGS84.ts
|
|
1566
|
+
var TRANSFORM_FN = {
|
|
1567
|
+
Point: transformPoint,
|
|
1568
|
+
MultiPoint: transformMultiPoint,
|
|
1569
|
+
LineString: transformLineString,
|
|
1570
|
+
MultiLineString: transformMultiLineString,
|
|
1571
|
+
Polygon: transformPolygon,
|
|
1572
|
+
MultiPolygon: transformMultiPolygon
|
|
1573
|
+
};
|
|
1574
|
+
function transformTileCoordsToWGS84(geometry, bbox2) {
|
|
1575
|
+
const [west, south, east, north] = bbox2;
|
|
1576
|
+
const nw = lngLatToWorld([west, north]);
|
|
1577
|
+
const se = lngLatToWorld([east, south]);
|
|
1578
|
+
const projectedBbox = [nw, se];
|
|
1579
|
+
if (geometry.type === "GeometryCollection") {
|
|
1580
|
+
throw new Error("Unsupported geometry type GeometryCollection");
|
|
1581
|
+
}
|
|
1582
|
+
const transformFn = TRANSFORM_FN[geometry.type];
|
|
1583
|
+
const coordinates = transformFn(geometry.coordinates, projectedBbox);
|
|
1584
|
+
return { ...geometry, coordinates };
|
|
1585
|
+
}
|
|
1586
|
+
function transformPoint([pointX, pointY], [nw, se]) {
|
|
1587
|
+
const x = lerp(nw[0], se[0], pointX);
|
|
1588
|
+
const y = lerp(nw[1], se[1], pointY);
|
|
1589
|
+
return worldToLngLat([x, y]);
|
|
1590
|
+
}
|
|
1591
|
+
function getPoints(geometry, bbox2) {
|
|
1592
|
+
return geometry.map((g) => transformPoint(g, bbox2));
|
|
1593
|
+
}
|
|
1594
|
+
function transformMultiPoint(multiPoint, bbox2) {
|
|
1595
|
+
return getPoints(multiPoint, bbox2);
|
|
1596
|
+
}
|
|
1597
|
+
function transformLineString(line, bbox2) {
|
|
1598
|
+
return getPoints(line, bbox2);
|
|
1599
|
+
}
|
|
1600
|
+
function transformMultiLineString(multiLineString2, bbox2) {
|
|
1601
|
+
return multiLineString2.map(
|
|
1602
|
+
(lineString2) => transformLineString(lineString2, bbox2)
|
|
1603
|
+
);
|
|
1604
|
+
}
|
|
1605
|
+
function transformPolygon(polygon2, bbox2) {
|
|
1606
|
+
return polygon2.map((polygonRing) => getPoints(polygonRing, bbox2));
|
|
1607
|
+
}
|
|
1608
|
+
function transformMultiPolygon(multiPolygon2, bbox2) {
|
|
1609
|
+
return multiPolygon2.map((polygon2) => transformPolygon(polygon2, bbox2));
|
|
1610
|
+
}
|
|
1611
|
+
|
|
1508
1612
|
// node_modules/@turf/bbox-polygon/dist/esm/index.js
|
|
1509
1613
|
function bboxPolygon(bbox2, options = {}) {
|
|
1510
1614
|
const west = Number(bbox2[0]);
|
|
@@ -1823,7 +1927,7 @@ var MAX_SAFE_INTEGER = 9007199254740991;
|
|
|
1823
1927
|
var POWS_TEN = [1, 10, 100, 1e3, 1e4, 1e5, 1e6, 1e7, 1e8, 1e9, 1e10, 1e11, 1e12, 1e13];
|
|
1824
1928
|
var SQRT_BASE = 1e7;
|
|
1825
1929
|
var MAX = 1e9;
|
|
1826
|
-
function
|
|
1930
|
+
function clone2(configObject) {
|
|
1827
1931
|
var div, convertBase, parseNumeric, P = BigNumber2.prototype = { constructor: BigNumber2, toString: null, valueOf: null }, ONE = new BigNumber2(1), DECIMAL_PLACES = 20, ROUNDING_MODE = 4, TO_EXP_NEG = -7, TO_EXP_POS = 21, MIN_EXP = -1e7, MAX_EXP = 1e7, CRYPTO = false, MODULO_MODE = 1, POW_PRECISION = 0, FORMAT = {
|
|
1828
1932
|
prefix: "",
|
|
1829
1933
|
groupSize: 3,
|
|
@@ -1949,7 +2053,7 @@ function clone(configObject) {
|
|
|
1949
2053
|
x.c = [x.e = 0];
|
|
1950
2054
|
}
|
|
1951
2055
|
}
|
|
1952
|
-
BigNumber2.clone =
|
|
2056
|
+
BigNumber2.clone = clone2;
|
|
1953
2057
|
BigNumber2.ROUND_UP = 0;
|
|
1954
2058
|
BigNumber2.ROUND_DOWN = 1;
|
|
1955
2059
|
BigNumber2.ROUND_CEIL = 2;
|
|
@@ -3152,7 +3256,7 @@ function toFixedPoint(str, e, z) {
|
|
|
3152
3256
|
}
|
|
3153
3257
|
return str;
|
|
3154
3258
|
}
|
|
3155
|
-
var BigNumber =
|
|
3259
|
+
var BigNumber = clone2();
|
|
3156
3260
|
var bignumber_default = BigNumber;
|
|
3157
3261
|
|
|
3158
3262
|
// node_modules/splaytree-ts/dist/esm/index.js
|
|
@@ -4721,117 +4825,7 @@ function intersect(features, options = {}) {
|
|
|
4721
4825
|
}
|
|
4722
4826
|
var turf_intersect_default = intersect;
|
|
4723
4827
|
|
|
4724
|
-
// node_modules/@math.gl/core/dist/lib/common.js
|
|
4725
|
-
var RADIANS_TO_DEGREES = 1 / Math.PI * 180;
|
|
4726
|
-
var DEGREES_TO_RADIANS = 1 / 180 * Math.PI;
|
|
4727
|
-
var DEFAULT_CONFIG = {
|
|
4728
|
-
EPSILON: 1e-12,
|
|
4729
|
-
debug: false,
|
|
4730
|
-
precision: 4,
|
|
4731
|
-
printTypes: false,
|
|
4732
|
-
printDegrees: false,
|
|
4733
|
-
printRowMajor: true,
|
|
4734
|
-
_cartographicRadians: false
|
|
4735
|
-
};
|
|
4736
|
-
globalThis.mathgl = globalThis.mathgl || { config: { ...DEFAULT_CONFIG } };
|
|
4737
|
-
var config = globalThis.mathgl.config;
|
|
4738
|
-
function isArray(value) {
|
|
4739
|
-
return Array.isArray(value) || ArrayBuffer.isView(value) && !(value instanceof DataView);
|
|
4740
|
-
}
|
|
4741
|
-
function lerp(a, b, t) {
|
|
4742
|
-
if (isArray(a)) {
|
|
4743
|
-
return a.map((ai, i) => lerp(ai, b[i], t));
|
|
4744
|
-
}
|
|
4745
|
-
return t * b + (1 - t) * a;
|
|
4746
|
-
}
|
|
4747
|
-
|
|
4748
|
-
// node_modules/@math.gl/web-mercator/dist/assert.js
|
|
4749
|
-
function assert2(condition, message) {
|
|
4750
|
-
if (!condition) {
|
|
4751
|
-
throw new Error(message || "@math.gl/web-mercator: assertion failed.");
|
|
4752
|
-
}
|
|
4753
|
-
}
|
|
4754
|
-
|
|
4755
|
-
// node_modules/@math.gl/web-mercator/dist/web-mercator-utils.js
|
|
4756
|
-
var PI = Math.PI;
|
|
4757
|
-
var PI_4 = PI / 4;
|
|
4758
|
-
var DEGREES_TO_RADIANS2 = PI / 180;
|
|
4759
|
-
var RADIANS_TO_DEGREES2 = 180 / PI;
|
|
4760
|
-
var TILE_SIZE = 512;
|
|
4761
|
-
function lngLatToWorld(lngLat) {
|
|
4762
|
-
const [lng, lat] = lngLat;
|
|
4763
|
-
assert2(Number.isFinite(lng));
|
|
4764
|
-
assert2(Number.isFinite(lat) && lat >= -90 && lat <= 90, "invalid latitude");
|
|
4765
|
-
const lambda2 = lng * DEGREES_TO_RADIANS2;
|
|
4766
|
-
const phi2 = lat * DEGREES_TO_RADIANS2;
|
|
4767
|
-
const x = TILE_SIZE * (lambda2 + PI) / (2 * PI);
|
|
4768
|
-
const y = TILE_SIZE * (PI + Math.log(Math.tan(PI_4 + phi2 * 0.5))) / (2 * PI);
|
|
4769
|
-
return [x, y];
|
|
4770
|
-
}
|
|
4771
|
-
function worldToLngLat(xy) {
|
|
4772
|
-
const [x, y] = xy;
|
|
4773
|
-
const lambda2 = x / TILE_SIZE * (2 * PI) - PI;
|
|
4774
|
-
const phi2 = 2 * (Math.atan(Math.exp(y / TILE_SIZE * (2 * PI) - PI)) - PI_4);
|
|
4775
|
-
return [lambda2 * RADIANS_TO_DEGREES2, phi2 * RADIANS_TO_DEGREES2];
|
|
4776
|
-
}
|
|
4777
|
-
|
|
4778
|
-
// node_modules/@math.gl/web-mercator/dist/get-bounds.js
|
|
4779
|
-
var DEGREES_TO_RADIANS3 = Math.PI / 180;
|
|
4780
|
-
|
|
4781
4828
|
// src/utils/transformToTileCoords.ts
|
|
4782
|
-
var TRANSFORM_FN = {
|
|
4783
|
-
Point: transformPoint,
|
|
4784
|
-
MultiPoint: transformMultiPoint,
|
|
4785
|
-
LineString: transformLineString,
|
|
4786
|
-
MultiLineString: transformMultiLineString,
|
|
4787
|
-
Polygon: transformPolygon,
|
|
4788
|
-
MultiPolygon: transformMultiPolygon
|
|
4789
|
-
};
|
|
4790
|
-
function transformToTileCoords(geometry, bbox2) {
|
|
4791
|
-
const [west, south, east, north] = bbox2;
|
|
4792
|
-
const nw = projectFlat([west, north]);
|
|
4793
|
-
const se = projectFlat([east, south]);
|
|
4794
|
-
const projectedBbox = [nw, se];
|
|
4795
|
-
if (geometry.type === "GeometryCollection") {
|
|
4796
|
-
throw new Error("Unsupported geometry type GeometryCollection");
|
|
4797
|
-
}
|
|
4798
|
-
const transformFn = TRANSFORM_FN[geometry.type];
|
|
4799
|
-
const coordinates = transformFn(geometry.coordinates, projectedBbox);
|
|
4800
|
-
return { ...geometry, coordinates };
|
|
4801
|
-
}
|
|
4802
|
-
function transformPoint([pointX, pointY], [nw, se]) {
|
|
4803
|
-
const x = inverseLerp(nw[0], se[0], pointX);
|
|
4804
|
-
const y = inverseLerp(nw[1], se[1], pointY);
|
|
4805
|
-
return [x, y];
|
|
4806
|
-
}
|
|
4807
|
-
function getPoints(geometry, bbox2) {
|
|
4808
|
-
return geometry.map((g) => transformPoint(projectFlat(g), bbox2));
|
|
4809
|
-
}
|
|
4810
|
-
function transformMultiPoint(multiPoint, bbox2) {
|
|
4811
|
-
return getPoints(multiPoint, bbox2);
|
|
4812
|
-
}
|
|
4813
|
-
function transformLineString(line, bbox2) {
|
|
4814
|
-
return getPoints(line, bbox2);
|
|
4815
|
-
}
|
|
4816
|
-
function transformMultiLineString(multiLineString2, bbox2) {
|
|
4817
|
-
return multiLineString2.map(
|
|
4818
|
-
(lineString2) => transformLineString(lineString2, bbox2)
|
|
4819
|
-
);
|
|
4820
|
-
}
|
|
4821
|
-
function transformPolygon(polygon2, bbox2) {
|
|
4822
|
-
return polygon2.map((polygonRing) => getPoints(polygonRing, bbox2));
|
|
4823
|
-
}
|
|
4824
|
-
function transformMultiPolygon(multiPolygon2, bbox2) {
|
|
4825
|
-
return multiPolygon2.map((polygon2) => transformPolygon(polygon2, bbox2));
|
|
4826
|
-
}
|
|
4827
|
-
function projectFlat(xyz) {
|
|
4828
|
-
return lngLatToWorld(xyz);
|
|
4829
|
-
}
|
|
4830
|
-
function inverseLerp(a, b, x) {
|
|
4831
|
-
return (x - a) / (b - a);
|
|
4832
|
-
}
|
|
4833
|
-
|
|
4834
|
-
// src/utils/transformTileCoordsToWGS84.ts
|
|
4835
4829
|
var TRANSFORM_FN2 = {
|
|
4836
4830
|
Point: transformPoint2,
|
|
4837
4831
|
MultiPoint: transformMultiPoint2,
|
|
@@ -4840,10 +4834,10 @@ var TRANSFORM_FN2 = {
|
|
|
4840
4834
|
Polygon: transformPolygon2,
|
|
4841
4835
|
MultiPolygon: transformMultiPolygon2
|
|
4842
4836
|
};
|
|
4843
|
-
function
|
|
4837
|
+
function transformToTileCoords(geometry, bbox2) {
|
|
4844
4838
|
const [west, south, east, north] = bbox2;
|
|
4845
|
-
const nw =
|
|
4846
|
-
const se =
|
|
4839
|
+
const nw = projectFlat([west, north]);
|
|
4840
|
+
const se = projectFlat([east, south]);
|
|
4847
4841
|
const projectedBbox = [nw, se];
|
|
4848
4842
|
if (geometry.type === "GeometryCollection") {
|
|
4849
4843
|
throw new Error("Unsupported geometry type GeometryCollection");
|
|
@@ -4853,12 +4847,12 @@ function transformTileCoordsToWGS84(geometry, bbox2) {
|
|
|
4853
4847
|
return { ...geometry, coordinates };
|
|
4854
4848
|
}
|
|
4855
4849
|
function transformPoint2([pointX, pointY], [nw, se]) {
|
|
4856
|
-
const x =
|
|
4857
|
-
const y =
|
|
4858
|
-
return
|
|
4850
|
+
const x = inverseLerp(nw[0], se[0], pointX);
|
|
4851
|
+
const y = inverseLerp(nw[1], se[1], pointY);
|
|
4852
|
+
return [x, y];
|
|
4859
4853
|
}
|
|
4860
4854
|
function getPoints2(geometry, bbox2) {
|
|
4861
|
-
return geometry.map((g) => transformPoint2(g, bbox2));
|
|
4855
|
+
return geometry.map((g) => transformPoint2(projectFlat(g), bbox2));
|
|
4862
4856
|
}
|
|
4863
4857
|
function transformMultiPoint2(multiPoint, bbox2) {
|
|
4864
4858
|
return getPoints2(multiPoint, bbox2);
|
|
@@ -4877,70 +4871,257 @@ function transformPolygon2(polygon2, bbox2) {
|
|
|
4877
4871
|
function transformMultiPolygon2(multiPolygon2, bbox2) {
|
|
4878
4872
|
return multiPolygon2.map((polygon2) => transformPolygon2(polygon2, bbox2));
|
|
4879
4873
|
}
|
|
4874
|
+
function projectFlat(xyz) {
|
|
4875
|
+
return lngLatToWorld(xyz);
|
|
4876
|
+
}
|
|
4877
|
+
function inverseLerp(a, b, x) {
|
|
4878
|
+
return (x - a) / (b - a);
|
|
4879
|
+
}
|
|
4880
4880
|
|
|
4881
|
-
// src/filters/
|
|
4882
|
-
|
|
4883
|
-
|
|
4884
|
-
|
|
4885
|
-
|
|
4886
|
-
|
|
4887
|
-
|
|
4888
|
-
|
|
4889
|
-
}
|
|
4890
|
-
|
|
4891
|
-
|
|
4892
|
-
|
|
4893
|
-
|
|
4894
|
-
|
|
4895
|
-
|
|
4896
|
-
|
|
4897
|
-
|
|
4898
|
-
|
|
4899
|
-
|
|
4900
|
-
|
|
4901
|
-
|
|
4902
|
-
|
|
4903
|
-
|
|
4904
|
-
|
|
4905
|
-
|
|
4906
|
-
|
|
4907
|
-
|
|
4908
|
-
|
|
4909
|
-
|
|
4910
|
-
|
|
4911
|
-
|
|
4912
|
-
|
|
4913
|
-
|
|
4914
|
-
|
|
4915
|
-
|
|
4916
|
-
|
|
4917
|
-
|
|
4918
|
-
|
|
4919
|
-
|
|
4881
|
+
// src/filters/tileIntersection.ts
|
|
4882
|
+
import {
|
|
4883
|
+
cellToBoundary as quadbinCellToBoundary,
|
|
4884
|
+
geometryToCells as quadbinGeometryToCells
|
|
4885
|
+
} from "quadbin";
|
|
4886
|
+
import {
|
|
4887
|
+
cellToBoundary as h3CellToBoundary,
|
|
4888
|
+
polygonToCells as h3PolygonToCells
|
|
4889
|
+
} from "h3-js";
|
|
4890
|
+
|
|
4891
|
+
// node_modules/@turf/bbox-clip/dist/esm/index.js
|
|
4892
|
+
function lineclip(points, bbox2, result) {
|
|
4893
|
+
var len = points.length, codeA = bitCode(points[0], bbox2), part = [], i, codeB, lastCode;
|
|
4894
|
+
let a;
|
|
4895
|
+
let b;
|
|
4896
|
+
if (!result) result = [];
|
|
4897
|
+
for (i = 1; i < len; i++) {
|
|
4898
|
+
a = points[i - 1];
|
|
4899
|
+
b = points[i];
|
|
4900
|
+
codeB = lastCode = bitCode(b, bbox2);
|
|
4901
|
+
while (true) {
|
|
4902
|
+
if (!(codeA | codeB)) {
|
|
4903
|
+
part.push(a);
|
|
4904
|
+
if (codeB !== lastCode) {
|
|
4905
|
+
part.push(b);
|
|
4906
|
+
if (i < len - 1) {
|
|
4907
|
+
result.push(part);
|
|
4908
|
+
part = [];
|
|
4909
|
+
}
|
|
4910
|
+
} else if (i === len - 1) {
|
|
4911
|
+
part.push(b);
|
|
4912
|
+
}
|
|
4913
|
+
break;
|
|
4914
|
+
} else if (codeA & codeB) {
|
|
4915
|
+
break;
|
|
4916
|
+
} else if (codeA) {
|
|
4917
|
+
a = intersect2(a, b, codeA, bbox2);
|
|
4918
|
+
codeA = bitCode(a, bbox2);
|
|
4919
|
+
} else {
|
|
4920
|
+
b = intersect2(a, b, codeB, bbox2);
|
|
4921
|
+
codeB = bitCode(b, bbox2);
|
|
4922
|
+
}
|
|
4923
|
+
}
|
|
4924
|
+
codeA = lastCode;
|
|
4925
|
+
}
|
|
4926
|
+
if (part.length) result.push(part);
|
|
4927
|
+
return result;
|
|
4928
|
+
}
|
|
4929
|
+
function polygonclip(points, bbox2) {
|
|
4930
|
+
var result, edge, prev, prevInside, i, p, inside;
|
|
4931
|
+
for (edge = 1; edge <= 8; edge *= 2) {
|
|
4932
|
+
result = [];
|
|
4933
|
+
prev = points[points.length - 1];
|
|
4934
|
+
prevInside = !(bitCode(prev, bbox2) & edge);
|
|
4935
|
+
for (i = 0; i < points.length; i++) {
|
|
4936
|
+
p = points[i];
|
|
4937
|
+
inside = !(bitCode(p, bbox2) & edge);
|
|
4938
|
+
if (inside !== prevInside) result.push(intersect2(prev, p, edge, bbox2));
|
|
4939
|
+
if (inside) result.push(p);
|
|
4940
|
+
prev = p;
|
|
4941
|
+
prevInside = inside;
|
|
4942
|
+
}
|
|
4943
|
+
points = result;
|
|
4944
|
+
if (!points.length) break;
|
|
4945
|
+
}
|
|
4946
|
+
return result;
|
|
4947
|
+
}
|
|
4948
|
+
function intersect2(a, b, edge, bbox2) {
|
|
4949
|
+
return edge & 8 ? [a[0] + (b[0] - a[0]) * (bbox2[3] - a[1]) / (b[1] - a[1]), bbox2[3]] : edge & 4 ? [a[0] + (b[0] - a[0]) * (bbox2[1] - a[1]) / (b[1] - a[1]), bbox2[1]] : edge & 2 ? [bbox2[2], a[1] + (b[1] - a[1]) * (bbox2[2] - a[0]) / (b[0] - a[0])] : edge & 1 ? [bbox2[0], a[1] + (b[1] - a[1]) * (bbox2[0] - a[0]) / (b[0] - a[0])] : null;
|
|
4950
|
+
}
|
|
4951
|
+
function bitCode(p, bbox2) {
|
|
4952
|
+
var code = 0;
|
|
4953
|
+
if (p[0] < bbox2[0]) code |= 1;
|
|
4954
|
+
else if (p[0] > bbox2[2]) code |= 2;
|
|
4955
|
+
if (p[1] < bbox2[1]) code |= 4;
|
|
4956
|
+
else if (p[1] > bbox2[3]) code |= 8;
|
|
4957
|
+
return code;
|
|
4958
|
+
}
|
|
4959
|
+
function bboxClip(feature2, bbox2) {
|
|
4960
|
+
const geom = getGeom(feature2);
|
|
4961
|
+
const type = geom.type;
|
|
4962
|
+
const properties = feature2.type === "Feature" ? feature2.properties : {};
|
|
4963
|
+
let coords = geom.coordinates;
|
|
4964
|
+
switch (type) {
|
|
4965
|
+
case "LineString":
|
|
4966
|
+
case "MultiLineString": {
|
|
4967
|
+
const lines = [];
|
|
4968
|
+
if (type === "LineString") {
|
|
4969
|
+
coords = [coords];
|
|
4970
|
+
}
|
|
4971
|
+
coords.forEach((line) => {
|
|
4972
|
+
lineclip(line, bbox2, lines);
|
|
4973
|
+
});
|
|
4974
|
+
if (lines.length === 1) {
|
|
4975
|
+
return lineString(lines[0], properties);
|
|
4976
|
+
}
|
|
4977
|
+
return multiLineString(lines, properties);
|
|
4978
|
+
}
|
|
4979
|
+
case "Polygon":
|
|
4980
|
+
return polygon(clipPolygon(coords, bbox2), properties);
|
|
4981
|
+
case "MultiPolygon":
|
|
4982
|
+
return multiPolygon(
|
|
4983
|
+
coords.map((poly) => {
|
|
4984
|
+
return clipPolygon(poly, bbox2);
|
|
4985
|
+
}),
|
|
4986
|
+
properties
|
|
4987
|
+
);
|
|
4988
|
+
default:
|
|
4989
|
+
throw new Error("geometry " + type + " not supported");
|
|
4990
|
+
}
|
|
4991
|
+
}
|
|
4992
|
+
function clipPolygon(rings, bbox2) {
|
|
4993
|
+
const outRings = [];
|
|
4994
|
+
for (const ring of rings) {
|
|
4995
|
+
const clipped = polygonclip(ring, bbox2);
|
|
4996
|
+
if (clipped.length > 0) {
|
|
4997
|
+
if (clipped[0][0] !== clipped[clipped.length - 1][0] || clipped[0][1] !== clipped[clipped.length - 1][1]) {
|
|
4998
|
+
clipped.push(clipped[0]);
|
|
4999
|
+
}
|
|
5000
|
+
if (clipped.length >= 4) {
|
|
5001
|
+
outRings.push(clipped);
|
|
5002
|
+
}
|
|
5003
|
+
}
|
|
5004
|
+
}
|
|
5005
|
+
return outRings;
|
|
5006
|
+
}
|
|
5007
|
+
var turf_bbox_clip_default = bboxClip;
|
|
5008
|
+
|
|
5009
|
+
// src/filters/tileIntersection.ts
|
|
5010
|
+
function intersectTileGeometry(tileBbox, tileFormat, spatialFilter) {
|
|
5011
|
+
const tilePolygon = turf_bbox_polygon_default(tileBbox);
|
|
5012
|
+
if (!spatialFilter || turf_boolean_within_default(tilePolygon, spatialFilter)) {
|
|
5013
|
+
return true;
|
|
5014
|
+
}
|
|
5015
|
+
const clippedSpatialFilter = turf_intersect_default(
|
|
5016
|
+
featureCollection([tilePolygon, feature(spatialFilter)])
|
|
5017
|
+
);
|
|
5018
|
+
if (!clippedSpatialFilter) {
|
|
5019
|
+
return false;
|
|
5020
|
+
}
|
|
5021
|
+
return tileFormat === "mvt" /* MVT */ ? transformToTileCoords(clippedSpatialFilter.geometry, tileBbox) : clippedSpatialFilter.geometry;
|
|
5022
|
+
}
|
|
5023
|
+
function intersectTileRaster(parent, cellResolution, spatialFilter) {
|
|
5024
|
+
return intersectTileQuadbin(parent, cellResolution, spatialFilter);
|
|
5025
|
+
}
|
|
5026
|
+
function intersectTileQuadbin(parent, cellResolution, spatialFilter) {
|
|
5027
|
+
const tilePolygon = quadbinCellToBoundary(parent);
|
|
5028
|
+
if (!spatialFilter || turf_boolean_within_default(tilePolygon, spatialFilter)) {
|
|
5029
|
+
return true;
|
|
5030
|
+
}
|
|
5031
|
+
const clippedSpatialFilter = turf_intersect_default(
|
|
5032
|
+
featureCollection([feature(tilePolygon), feature(spatialFilter)])
|
|
5033
|
+
);
|
|
5034
|
+
if (!clippedSpatialFilter) {
|
|
5035
|
+
return false;
|
|
5036
|
+
}
|
|
5037
|
+
const cells = quadbinGeometryToCells(
|
|
5038
|
+
clippedSpatialFilter.geometry,
|
|
5039
|
+
cellResolution
|
|
5040
|
+
);
|
|
5041
|
+
return new Set(cells);
|
|
5042
|
+
}
|
|
5043
|
+
var BBOX_WEST = [-180, -90, 0, 90];
|
|
5044
|
+
var BBOX_EAST = [0, -90, 180, 90];
|
|
5045
|
+
function intersectTileH3(parent, cellResolution, spatialFilter) {
|
|
5046
|
+
const tilePolygon = {
|
|
5047
|
+
type: "Polygon",
|
|
5048
|
+
coordinates: [h3CellToBoundary(parent, true)]
|
|
5049
|
+
};
|
|
5050
|
+
if (!spatialFilter || turf_boolean_within_default(tilePolygon, spatialFilter)) {
|
|
5051
|
+
return true;
|
|
5052
|
+
}
|
|
5053
|
+
const clippedSpatialFilter = turf_intersect_default(
|
|
5054
|
+
featureCollection([feature(tilePolygon), feature(spatialFilter)])
|
|
5055
|
+
);
|
|
5056
|
+
if (!clippedSpatialFilter) {
|
|
5057
|
+
return false;
|
|
5058
|
+
}
|
|
5059
|
+
const cellsWest = h3PolygonToCells(
|
|
5060
|
+
turf_bbox_clip_default(clippedSpatialFilter, BBOX_WEST).geometry.coordinates,
|
|
5061
|
+
cellResolution,
|
|
5062
|
+
true
|
|
5063
|
+
);
|
|
5064
|
+
const cellsEast = h3PolygonToCells(
|
|
5065
|
+
turf_bbox_clip_default(clippedSpatialFilter, BBOX_EAST).geometry.coordinates,
|
|
5066
|
+
cellResolution,
|
|
5067
|
+
true
|
|
5068
|
+
);
|
|
5069
|
+
return new Set(cellsWest.concat(cellsEast));
|
|
5070
|
+
}
|
|
5071
|
+
|
|
5072
|
+
// src/filters/tileFeaturesGeometries.ts
|
|
5073
|
+
var FEATURE_GEOM_PROPERTY = "__geomValue";
|
|
5074
|
+
function tileFeaturesGeometries({
|
|
5075
|
+
tiles,
|
|
5076
|
+
tileFormat,
|
|
5077
|
+
spatialFilter,
|
|
5078
|
+
uniqueIdProperty,
|
|
5079
|
+
options
|
|
5080
|
+
}) {
|
|
5081
|
+
const map = /* @__PURE__ */ new Map();
|
|
5082
|
+
for (const tile of tiles) {
|
|
5083
|
+
if (tile.isVisible === false || !tile.data) {
|
|
5084
|
+
continue;
|
|
5085
|
+
}
|
|
5086
|
+
const tileBbox = [
|
|
5087
|
+
tile.bbox.west,
|
|
5088
|
+
tile.bbox.south,
|
|
5089
|
+
tile.bbox.east,
|
|
5090
|
+
tile.bbox.north
|
|
5091
|
+
];
|
|
5092
|
+
const intersection3 = intersectTileGeometry(
|
|
5093
|
+
tileBbox,
|
|
5094
|
+
tileFormat,
|
|
5095
|
+
spatialFilter
|
|
5096
|
+
);
|
|
5097
|
+
if (intersection3 === false) continue;
|
|
5098
|
+
const transformedSpatialFilter = intersection3 === true ? void 0 : intersection3;
|
|
5099
|
+
calculateFeatures({
|
|
5100
|
+
map,
|
|
5101
|
+
spatialFilter: transformedSpatialFilter,
|
|
5102
|
+
data: tile.data.points,
|
|
4920
5103
|
type: "Point",
|
|
4921
|
-
bbox:
|
|
5104
|
+
bbox: tileBbox,
|
|
4922
5105
|
tileFormat,
|
|
4923
5106
|
uniqueIdProperty,
|
|
4924
5107
|
options
|
|
4925
5108
|
});
|
|
4926
5109
|
calculateFeatures({
|
|
4927
5110
|
map,
|
|
4928
|
-
|
|
4929
|
-
geometryIntersection: transformedGeometryToIntersect,
|
|
5111
|
+
spatialFilter: transformedSpatialFilter,
|
|
4930
5112
|
data: tile.data.lines,
|
|
4931
5113
|
type: "LineString",
|
|
4932
|
-
bbox:
|
|
5114
|
+
bbox: tileBbox,
|
|
4933
5115
|
tileFormat,
|
|
4934
5116
|
uniqueIdProperty,
|
|
4935
5117
|
options
|
|
4936
5118
|
});
|
|
4937
5119
|
calculateFeatures({
|
|
4938
5120
|
map,
|
|
4939
|
-
|
|
4940
|
-
geometryIntersection: transformedGeometryToIntersect,
|
|
5121
|
+
spatialFilter: transformedSpatialFilter,
|
|
4941
5122
|
data: tile.data.polygons,
|
|
4942
5123
|
type: "Polygon",
|
|
4943
|
-
bbox:
|
|
5124
|
+
bbox: tileBbox,
|
|
4944
5125
|
tileFormat,
|
|
4945
5126
|
uniqueIdProperty,
|
|
4946
5127
|
options
|
|
@@ -4958,7 +5139,7 @@ function processTileFeatureProperties({
|
|
|
4958
5139
|
tileFormat,
|
|
4959
5140
|
uniqueIdProperty,
|
|
4960
5141
|
storeGeometry,
|
|
4961
|
-
|
|
5142
|
+
spatialFilter
|
|
4962
5143
|
}) {
|
|
4963
5144
|
const tileProps = getPropertiesFromTile(data, startIndex);
|
|
4964
5145
|
const uniquePropertyValue = getUniquePropertyValue(
|
|
@@ -4970,7 +5151,7 @@ function processTileFeatureProperties({
|
|
|
4970
5151
|
return;
|
|
4971
5152
|
}
|
|
4972
5153
|
let geometry = null;
|
|
4973
|
-
if (storeGeometry ||
|
|
5154
|
+
if (storeGeometry || spatialFilter) {
|
|
4974
5155
|
const { positions } = data;
|
|
4975
5156
|
const ringCoordinates = getRingCoordinatesFor(
|
|
4976
5157
|
startIndex,
|
|
@@ -4979,7 +5160,7 @@ function processTileFeatureProperties({
|
|
|
4979
5160
|
);
|
|
4980
5161
|
geometry = getFeatureByType(ringCoordinates, type);
|
|
4981
5162
|
}
|
|
4982
|
-
if (geometry &&
|
|
5163
|
+
if (geometry && spatialFilter && !turf_boolean_intersects_default(geometry, spatialFilter)) {
|
|
4983
5164
|
return;
|
|
4984
5165
|
}
|
|
4985
5166
|
const properties = parseProperties(tileProps);
|
|
@@ -4991,7 +5172,7 @@ function processTileFeatureProperties({
|
|
|
4991
5172
|
function addIntersectedFeaturesInTile({
|
|
4992
5173
|
map,
|
|
4993
5174
|
data,
|
|
4994
|
-
|
|
5175
|
+
spatialFilter,
|
|
4995
5176
|
type,
|
|
4996
5177
|
bbox: bbox2,
|
|
4997
5178
|
tileFormat,
|
|
@@ -5013,7 +5194,7 @@ function addIntersectedFeaturesInTile({
|
|
|
5013
5194
|
tileFormat,
|
|
5014
5195
|
uniqueIdProperty,
|
|
5015
5196
|
storeGeometry,
|
|
5016
|
-
|
|
5197
|
+
spatialFilter
|
|
5017
5198
|
});
|
|
5018
5199
|
}
|
|
5019
5200
|
}
|
|
@@ -5095,8 +5276,7 @@ function getRingCoordinatesFor(startIndex, endIndex, positions) {
|
|
|
5095
5276
|
}
|
|
5096
5277
|
function calculateFeatures({
|
|
5097
5278
|
map,
|
|
5098
|
-
|
|
5099
|
-
geometryIntersection,
|
|
5279
|
+
spatialFilter,
|
|
5100
5280
|
data,
|
|
5101
5281
|
type,
|
|
5102
5282
|
bbox: bbox2,
|
|
@@ -5107,7 +5287,7 @@ function calculateFeatures({
|
|
|
5107
5287
|
if (!data?.properties.length) {
|
|
5108
5288
|
return;
|
|
5109
5289
|
}
|
|
5110
|
-
if (
|
|
5290
|
+
if (!spatialFilter) {
|
|
5111
5291
|
addAllFeaturesInTile({
|
|
5112
5292
|
map,
|
|
5113
5293
|
data,
|
|
@@ -5121,7 +5301,7 @@ function calculateFeatures({
|
|
|
5121
5301
|
addIntersectedFeaturesInTile({
|
|
5122
5302
|
map,
|
|
5123
5303
|
data,
|
|
5124
|
-
|
|
5304
|
+
spatialFilter,
|
|
5125
5305
|
type,
|
|
5126
5306
|
bbox: bbox2,
|
|
5127
5307
|
tileFormat,
|
|
@@ -5171,128 +5351,8 @@ function createIndicesForPoints(data) {
|
|
|
5171
5351
|
}
|
|
5172
5352
|
|
|
5173
5353
|
// src/filters/tileFeaturesSpatialIndex.ts
|
|
5174
|
-
import { getResolution as quadbinGetResolution
|
|
5175
|
-
|
|
5176
|
-
// node_modules/@turf/bbox-clip/dist/esm/index.js
|
|
5177
|
-
function lineclip(points, bbox2, result) {
|
|
5178
|
-
var len = points.length, codeA = bitCode(points[0], bbox2), part = [], i, codeB, lastCode;
|
|
5179
|
-
let a;
|
|
5180
|
-
let b;
|
|
5181
|
-
if (!result) result = [];
|
|
5182
|
-
for (i = 1; i < len; i++) {
|
|
5183
|
-
a = points[i - 1];
|
|
5184
|
-
b = points[i];
|
|
5185
|
-
codeB = lastCode = bitCode(b, bbox2);
|
|
5186
|
-
while (true) {
|
|
5187
|
-
if (!(codeA | codeB)) {
|
|
5188
|
-
part.push(a);
|
|
5189
|
-
if (codeB !== lastCode) {
|
|
5190
|
-
part.push(b);
|
|
5191
|
-
if (i < len - 1) {
|
|
5192
|
-
result.push(part);
|
|
5193
|
-
part = [];
|
|
5194
|
-
}
|
|
5195
|
-
} else if (i === len - 1) {
|
|
5196
|
-
part.push(b);
|
|
5197
|
-
}
|
|
5198
|
-
break;
|
|
5199
|
-
} else if (codeA & codeB) {
|
|
5200
|
-
break;
|
|
5201
|
-
} else if (codeA) {
|
|
5202
|
-
a = intersect2(a, b, codeA, bbox2);
|
|
5203
|
-
codeA = bitCode(a, bbox2);
|
|
5204
|
-
} else {
|
|
5205
|
-
b = intersect2(a, b, codeB, bbox2);
|
|
5206
|
-
codeB = bitCode(b, bbox2);
|
|
5207
|
-
}
|
|
5208
|
-
}
|
|
5209
|
-
codeA = lastCode;
|
|
5210
|
-
}
|
|
5211
|
-
if (part.length) result.push(part);
|
|
5212
|
-
return result;
|
|
5213
|
-
}
|
|
5214
|
-
function polygonclip(points, bbox2) {
|
|
5215
|
-
var result, edge, prev, prevInside, i, p, inside;
|
|
5216
|
-
for (edge = 1; edge <= 8; edge *= 2) {
|
|
5217
|
-
result = [];
|
|
5218
|
-
prev = points[points.length - 1];
|
|
5219
|
-
prevInside = !(bitCode(prev, bbox2) & edge);
|
|
5220
|
-
for (i = 0; i < points.length; i++) {
|
|
5221
|
-
p = points[i];
|
|
5222
|
-
inside = !(bitCode(p, bbox2) & edge);
|
|
5223
|
-
if (inside !== prevInside) result.push(intersect2(prev, p, edge, bbox2));
|
|
5224
|
-
if (inside) result.push(p);
|
|
5225
|
-
prev = p;
|
|
5226
|
-
prevInside = inside;
|
|
5227
|
-
}
|
|
5228
|
-
points = result;
|
|
5229
|
-
if (!points.length) break;
|
|
5230
|
-
}
|
|
5231
|
-
return result;
|
|
5232
|
-
}
|
|
5233
|
-
function intersect2(a, b, edge, bbox2) {
|
|
5234
|
-
return edge & 8 ? [a[0] + (b[0] - a[0]) * (bbox2[3] - a[1]) / (b[1] - a[1]), bbox2[3]] : edge & 4 ? [a[0] + (b[0] - a[0]) * (bbox2[1] - a[1]) / (b[1] - a[1]), bbox2[1]] : edge & 2 ? [bbox2[2], a[1] + (b[1] - a[1]) * (bbox2[2] - a[0]) / (b[0] - a[0])] : edge & 1 ? [bbox2[0], a[1] + (b[1] - a[1]) * (bbox2[0] - a[0]) / (b[0] - a[0])] : null;
|
|
5235
|
-
}
|
|
5236
|
-
function bitCode(p, bbox2) {
|
|
5237
|
-
var code = 0;
|
|
5238
|
-
if (p[0] < bbox2[0]) code |= 1;
|
|
5239
|
-
else if (p[0] > bbox2[2]) code |= 2;
|
|
5240
|
-
if (p[1] < bbox2[1]) code |= 4;
|
|
5241
|
-
else if (p[1] > bbox2[3]) code |= 8;
|
|
5242
|
-
return code;
|
|
5243
|
-
}
|
|
5244
|
-
function bboxClip(feature2, bbox2) {
|
|
5245
|
-
const geom = getGeom(feature2);
|
|
5246
|
-
const type = geom.type;
|
|
5247
|
-
const properties = feature2.type === "Feature" ? feature2.properties : {};
|
|
5248
|
-
let coords = geom.coordinates;
|
|
5249
|
-
switch (type) {
|
|
5250
|
-
case "LineString":
|
|
5251
|
-
case "MultiLineString": {
|
|
5252
|
-
const lines = [];
|
|
5253
|
-
if (type === "LineString") {
|
|
5254
|
-
coords = [coords];
|
|
5255
|
-
}
|
|
5256
|
-
coords.forEach((line) => {
|
|
5257
|
-
lineclip(line, bbox2, lines);
|
|
5258
|
-
});
|
|
5259
|
-
if (lines.length === 1) {
|
|
5260
|
-
return lineString(lines[0], properties);
|
|
5261
|
-
}
|
|
5262
|
-
return multiLineString(lines, properties);
|
|
5263
|
-
}
|
|
5264
|
-
case "Polygon":
|
|
5265
|
-
return polygon(clipPolygon(coords, bbox2), properties);
|
|
5266
|
-
case "MultiPolygon":
|
|
5267
|
-
return multiPolygon(
|
|
5268
|
-
coords.map((poly) => {
|
|
5269
|
-
return clipPolygon(poly, bbox2);
|
|
5270
|
-
}),
|
|
5271
|
-
properties
|
|
5272
|
-
);
|
|
5273
|
-
default:
|
|
5274
|
-
throw new Error("geometry " + type + " not supported");
|
|
5275
|
-
}
|
|
5276
|
-
}
|
|
5277
|
-
function clipPolygon(rings, bbox2) {
|
|
5278
|
-
const outRings = [];
|
|
5279
|
-
for (const ring of rings) {
|
|
5280
|
-
const clipped = polygonclip(ring, bbox2);
|
|
5281
|
-
if (clipped.length > 0) {
|
|
5282
|
-
if (clipped[0][0] !== clipped[clipped.length - 1][0] || clipped[0][1] !== clipped[clipped.length - 1][1]) {
|
|
5283
|
-
clipped.push(clipped[0]);
|
|
5284
|
-
}
|
|
5285
|
-
if (clipped.length >= 4) {
|
|
5286
|
-
outRings.push(clipped);
|
|
5287
|
-
}
|
|
5288
|
-
}
|
|
5289
|
-
}
|
|
5290
|
-
return outRings;
|
|
5291
|
-
}
|
|
5292
|
-
var turf_bbox_clip_default = bboxClip;
|
|
5293
|
-
|
|
5294
|
-
// src/filters/tileFeaturesSpatialIndex.ts
|
|
5295
|
-
import { getResolution as h3GetResolution, polygonToCells } from "h3-js";
|
|
5354
|
+
import { getResolution as quadbinGetResolution } from "quadbin";
|
|
5355
|
+
import { getResolution as h3GetResolution } from "h3-js";
|
|
5296
5356
|
function tileFeaturesSpatialIndex({
|
|
5297
5357
|
tiles,
|
|
5298
5358
|
spatialFilter,
|
|
@@ -5301,28 +5361,40 @@ function tileFeaturesSpatialIndex({
|
|
|
5301
5361
|
}) {
|
|
5302
5362
|
const map = /* @__PURE__ */ new Map();
|
|
5303
5363
|
const spatialIndex = getSpatialIndex(spatialDataType);
|
|
5304
|
-
const
|
|
5364
|
+
const cellResolution = getResolution(tiles, spatialIndex);
|
|
5305
5365
|
const spatialIndexIDName = spatialDataColumn ? spatialDataColumn : spatialIndex;
|
|
5306
|
-
if (!
|
|
5366
|
+
if (!cellResolution) {
|
|
5307
5367
|
return [];
|
|
5308
5368
|
}
|
|
5309
|
-
const cells = getCellsCoverGeometry(spatialFilter, spatialIndex, resolution);
|
|
5310
|
-
if (!cells?.length) {
|
|
5311
|
-
return [];
|
|
5312
|
-
}
|
|
5313
|
-
const cellsSet = new Set(cells);
|
|
5314
5369
|
for (const tile of tiles) {
|
|
5315
5370
|
if (tile.isVisible === false || !tile.data) {
|
|
5316
5371
|
continue;
|
|
5317
5372
|
}
|
|
5373
|
+
const parent = getTileIndex(tile, spatialIndex);
|
|
5374
|
+
const intersection3 = spatialIndex === "quadbin" /* QUADBIN */ ? intersectTileQuadbin(
|
|
5375
|
+
parent,
|
|
5376
|
+
cellResolution,
|
|
5377
|
+
spatialFilter
|
|
5378
|
+
) : intersectTileH3(
|
|
5379
|
+
parent,
|
|
5380
|
+
cellResolution,
|
|
5381
|
+
spatialFilter
|
|
5382
|
+
);
|
|
5383
|
+
if (!intersection3) continue;
|
|
5318
5384
|
tile.data.forEach((d) => {
|
|
5319
|
-
if (
|
|
5385
|
+
if (intersection3 === true || intersection3.has(d.id)) {
|
|
5320
5386
|
map.set(d.id, { ...d.properties, [spatialIndexIDName]: d.id });
|
|
5321
5387
|
}
|
|
5322
5388
|
});
|
|
5323
5389
|
}
|
|
5324
5390
|
return Array.from(map.values());
|
|
5325
5391
|
}
|
|
5392
|
+
function getTileIndex(tile, spatialIndex) {
|
|
5393
|
+
if (spatialIndex === "quadbin" /* QUADBIN */) {
|
|
5394
|
+
return tile.index.q;
|
|
5395
|
+
}
|
|
5396
|
+
return tile.id;
|
|
5397
|
+
}
|
|
5326
5398
|
function getResolution(tiles, spatialIndex) {
|
|
5327
5399
|
const data = tiles.find((tile) => tile.data?.length)?.data;
|
|
5328
5400
|
if (!data) {
|
|
@@ -5335,26 +5407,6 @@ function getResolution(tiles, spatialIndex) {
|
|
|
5335
5407
|
return h3GetResolution(data[0].id);
|
|
5336
5408
|
}
|
|
5337
5409
|
}
|
|
5338
|
-
var bboxWest = [-180, -90, 0, 90];
|
|
5339
|
-
var bboxEast = [0, -90, 180, 90];
|
|
5340
|
-
function getCellsCoverGeometry(geometry, spatialIndex, resolution) {
|
|
5341
|
-
if (spatialIndex === "quadbin" /* QUADBIN */) {
|
|
5342
|
-
return geometryToCells(geometry, resolution);
|
|
5343
|
-
}
|
|
5344
|
-
if (spatialIndex === "h3" /* H3 */) {
|
|
5345
|
-
return polygonToCells(
|
|
5346
|
-
turf_bbox_clip_default(geometry, bboxWest).geometry.coordinates,
|
|
5347
|
-
resolution,
|
|
5348
|
-
true
|
|
5349
|
-
).concat(
|
|
5350
|
-
polygonToCells(
|
|
5351
|
-
turf_bbox_clip_default(geometry, bboxEast).geometry.coordinates,
|
|
5352
|
-
resolution,
|
|
5353
|
-
true
|
|
5354
|
-
)
|
|
5355
|
-
);
|
|
5356
|
-
}
|
|
5357
|
-
}
|
|
5358
5410
|
function getSpatialIndex(spatialDataType) {
|
|
5359
5411
|
switch (spatialDataType) {
|
|
5360
5412
|
case "h3":
|
|
@@ -5375,7 +5427,6 @@ var DEFAULT_AGGREGATION_EXP = `1 AS ${DEFAULT_AGGREGATION_EXP_ALIAS}`;
|
|
|
5375
5427
|
import {
|
|
5376
5428
|
cellToChildren as _cellToChildren,
|
|
5377
5429
|
cellToTile,
|
|
5378
|
-
geometryToCells as geometryToCells2,
|
|
5379
5430
|
getResolution as getResolution2
|
|
5380
5431
|
} from "quadbin";
|
|
5381
5432
|
function tileFeaturesRaster({
|
|
@@ -5391,15 +5442,20 @@ function tileFeaturesRaster({
|
|
|
5391
5442
|
const tileResolution = getResolution2(tiles[0].index.q);
|
|
5392
5443
|
const tileBlockSize = tiles[0].data.blockSize;
|
|
5393
5444
|
const cellResolution = tileResolution + BigInt(Math.log2(tileBlockSize));
|
|
5394
|
-
const spatialFilterCells = new Set(
|
|
5395
|
-
geometryToCells2(options.spatialFilter, cellResolution)
|
|
5396
|
-
);
|
|
5397
5445
|
const data = /* @__PURE__ */ new Map();
|
|
5398
5446
|
for (const tile of tiles) {
|
|
5399
5447
|
const parent = tile.index.q;
|
|
5400
|
-
const
|
|
5401
|
-
|
|
5402
|
-
|
|
5448
|
+
const intersection3 = intersectTileRaster(
|
|
5449
|
+
parent,
|
|
5450
|
+
cellResolution,
|
|
5451
|
+
options.spatialFilter
|
|
5452
|
+
);
|
|
5453
|
+
if (intersection3 === false) continue;
|
|
5454
|
+
const tileSortedCells = cellToChildrenSorted(parent, cellResolution);
|
|
5455
|
+
for (let i = 0; i < tileSortedCells.length; i++) {
|
|
5456
|
+
if (intersection3 !== true && !intersection3.has(tileSortedCells[i])) {
|
|
5457
|
+
continue;
|
|
5458
|
+
}
|
|
5403
5459
|
const cellData = {};
|
|
5404
5460
|
let cellDataExists = false;
|
|
5405
5461
|
for (const band in tile.data.cells.numericProps) {
|
|
@@ -5411,7 +5467,7 @@ function tileFeaturesRaster({
|
|
|
5411
5467
|
}
|
|
5412
5468
|
}
|
|
5413
5469
|
if (cellDataExists) {
|
|
5414
|
-
data.set(
|
|
5470
|
+
data.set(tileSortedCells[i], cellData);
|
|
5415
5471
|
}
|
|
5416
5472
|
}
|
|
5417
5473
|
}
|
|
@@ -6192,7 +6248,7 @@ var WidgetTilesetSourceImpl = class extends WidgetSource {
|
|
|
6192
6248
|
}
|
|
6193
6249
|
_extractTileFeatures(spatialFilter) {
|
|
6194
6250
|
const prevInputs = this._tileFeatureExtractPreviousInputs;
|
|
6195
|
-
if (this._features.length &&
|
|
6251
|
+
if (this._features.length && spatialFilterEquals(prevInputs.spatialFilter, spatialFilter)) {
|
|
6196
6252
|
return;
|
|
6197
6253
|
}
|
|
6198
6254
|
this._features = tileFeatures({
|
|
@@ -6432,7 +6488,6 @@ var WidgetTilesetSourceImpl = class extends WidgetSource {
|
|
|
6432
6488
|
* INTERNAL
|
|
6433
6489
|
*/
|
|
6434
6490
|
_getFilteredFeatures(spatialFilter, filters, filterOwner) {
|
|
6435
|
-
assert(spatialFilter, "spatialFilter required for tilesets");
|
|
6436
6491
|
this._extractTileFeatures(spatialFilter);
|
|
6437
6492
|
return applyFilters(
|
|
6438
6493
|
this._features,
|
|
@@ -6456,6 +6511,11 @@ function assertColumn(features, ...columnArgs) {
|
|
|
6456
6511
|
function normalizeColumns(columns) {
|
|
6457
6512
|
return Array.isArray(columns) ? columns : typeof columns === "string" ? [columns] : [];
|
|
6458
6513
|
}
|
|
6514
|
+
function spatialFilterEquals(a, b) {
|
|
6515
|
+
if (a === b) return true;
|
|
6516
|
+
if (!a || !b) return false;
|
|
6517
|
+
return booleanEqual(a, b);
|
|
6518
|
+
}
|
|
6459
6519
|
|
|
6460
6520
|
// src/workers/widget-tileset-worker.ts
|
|
6461
6521
|
var source;
|