@carto/api-client 0.5.7-alpha-optional-spatial-filter.0 → 0.5.7-alpha-others-orderby.1
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 +437 -414
- package/build/api-client.cjs.map +1 -1
- package/build/api-client.d.cts +45 -17
- package/build/api-client.d.ts +45 -17
- package/build/api-client.js +401 -382
- package/build/api-client.js.map +1 -1
- package/build/worker-compat.js +865 -900
- package/build/worker-compat.js.map +1 -1
- package/build/worker.js +374 -378
- package/build/worker.js.map +1 -1
- package/package.json +1 -1
- package/src/filters/tileFeatures.ts +1 -1
- package/src/filters/tileFeaturesGeometries.ts +55 -28
- package/src/filters/tileFeaturesRaster.ts +21 -10
- package/src/filters/tileFeaturesSpatialIndex.ts +52 -37
- package/src/operations/groupBy.ts +61 -12
- package/src/operations/groupByDate.ts +6 -1
- package/src/widget-sources/constants.ts +6 -0
- package/src/widget-sources/index.ts +1 -0
- package/src/widget-sources/types.ts +25 -1
- package/src/widget-sources/widget-remote-source.ts +28 -5
- package/src/widget-sources/widget-tileset-source-impl.ts +23 -10
- package/src/filters/tileIntersection.ts +0 -158
package/build/api-client.js
CHANGED
|
@@ -1558,110 +1558,6 @@ function geojsonFeatures({
|
|
|
1558
1558
|
return Array.from(map.values());
|
|
1559
1559
|
}
|
|
1560
1560
|
|
|
1561
|
-
// node_modules/@math.gl/core/dist/lib/common.js
|
|
1562
|
-
var RADIANS_TO_DEGREES = 1 / Math.PI * 180;
|
|
1563
|
-
var DEGREES_TO_RADIANS = 1 / 180 * Math.PI;
|
|
1564
|
-
var DEFAULT_CONFIG = {
|
|
1565
|
-
EPSILON: 1e-12,
|
|
1566
|
-
debug: false,
|
|
1567
|
-
precision: 4,
|
|
1568
|
-
printTypes: false,
|
|
1569
|
-
printDegrees: false,
|
|
1570
|
-
printRowMajor: true,
|
|
1571
|
-
_cartographicRadians: false
|
|
1572
|
-
};
|
|
1573
|
-
globalThis.mathgl = globalThis.mathgl || { config: { ...DEFAULT_CONFIG } };
|
|
1574
|
-
var config = globalThis.mathgl.config;
|
|
1575
|
-
function isArray(value) {
|
|
1576
|
-
return Array.isArray(value) || ArrayBuffer.isView(value) && !(value instanceof DataView);
|
|
1577
|
-
}
|
|
1578
|
-
function lerp(a, b, t) {
|
|
1579
|
-
if (isArray(a)) {
|
|
1580
|
-
return a.map((ai, i) => lerp(ai, b[i], t));
|
|
1581
|
-
}
|
|
1582
|
-
return t * b + (1 - t) * a;
|
|
1583
|
-
}
|
|
1584
|
-
|
|
1585
|
-
// node_modules/@math.gl/web-mercator/dist/assert.js
|
|
1586
|
-
function assert(condition, message) {
|
|
1587
|
-
if (!condition) {
|
|
1588
|
-
throw new Error(message || "@math.gl/web-mercator: assertion failed.");
|
|
1589
|
-
}
|
|
1590
|
-
}
|
|
1591
|
-
|
|
1592
|
-
// node_modules/@math.gl/web-mercator/dist/web-mercator-utils.js
|
|
1593
|
-
var PI = Math.PI;
|
|
1594
|
-
var PI_4 = PI / 4;
|
|
1595
|
-
var DEGREES_TO_RADIANS2 = PI / 180;
|
|
1596
|
-
var RADIANS_TO_DEGREES2 = 180 / PI;
|
|
1597
|
-
var TILE_SIZE = 512;
|
|
1598
|
-
function lngLatToWorld(lngLat) {
|
|
1599
|
-
const [lng, lat] = lngLat;
|
|
1600
|
-
assert(Number.isFinite(lng));
|
|
1601
|
-
assert(Number.isFinite(lat) && lat >= -90 && lat <= 90, "invalid latitude");
|
|
1602
|
-
const lambda2 = lng * DEGREES_TO_RADIANS2;
|
|
1603
|
-
const phi2 = lat * DEGREES_TO_RADIANS2;
|
|
1604
|
-
const x = TILE_SIZE * (lambda2 + PI) / (2 * PI);
|
|
1605
|
-
const y = TILE_SIZE * (PI + Math.log(Math.tan(PI_4 + phi2 * 0.5))) / (2 * PI);
|
|
1606
|
-
return [x, y];
|
|
1607
|
-
}
|
|
1608
|
-
function worldToLngLat(xy) {
|
|
1609
|
-
const [x, y] = xy;
|
|
1610
|
-
const lambda2 = x / TILE_SIZE * (2 * PI) - PI;
|
|
1611
|
-
const phi2 = 2 * (Math.atan(Math.exp(y / TILE_SIZE * (2 * PI) - PI)) - PI_4);
|
|
1612
|
-
return [lambda2 * RADIANS_TO_DEGREES2, phi2 * RADIANS_TO_DEGREES2];
|
|
1613
|
-
}
|
|
1614
|
-
|
|
1615
|
-
// node_modules/@math.gl/web-mercator/dist/get-bounds.js
|
|
1616
|
-
var DEGREES_TO_RADIANS3 = Math.PI / 180;
|
|
1617
|
-
|
|
1618
|
-
// src/utils/transformTileCoordsToWGS84.ts
|
|
1619
|
-
var TRANSFORM_FN = {
|
|
1620
|
-
Point: transformPoint,
|
|
1621
|
-
MultiPoint: transformMultiPoint,
|
|
1622
|
-
LineString: transformLineString,
|
|
1623
|
-
MultiLineString: transformMultiLineString,
|
|
1624
|
-
Polygon: transformPolygon,
|
|
1625
|
-
MultiPolygon: transformMultiPolygon
|
|
1626
|
-
};
|
|
1627
|
-
function transformTileCoordsToWGS84(geometry, bbox2) {
|
|
1628
|
-
const [west, south, east, north] = bbox2;
|
|
1629
|
-
const nw = lngLatToWorld([west, north]);
|
|
1630
|
-
const se = lngLatToWorld([east, south]);
|
|
1631
|
-
const projectedBbox = [nw, se];
|
|
1632
|
-
if (geometry.type === "GeometryCollection") {
|
|
1633
|
-
throw new Error("Unsupported geometry type GeometryCollection");
|
|
1634
|
-
}
|
|
1635
|
-
const transformFn = TRANSFORM_FN[geometry.type];
|
|
1636
|
-
const coordinates = transformFn(geometry.coordinates, projectedBbox);
|
|
1637
|
-
return { ...geometry, coordinates };
|
|
1638
|
-
}
|
|
1639
|
-
function transformPoint([pointX, pointY], [nw, se]) {
|
|
1640
|
-
const x = lerp(nw[0], se[0], pointX);
|
|
1641
|
-
const y = lerp(nw[1], se[1], pointY);
|
|
1642
|
-
return worldToLngLat([x, y]);
|
|
1643
|
-
}
|
|
1644
|
-
function getPoints(geometry, bbox2) {
|
|
1645
|
-
return geometry.map((g) => transformPoint(g, bbox2));
|
|
1646
|
-
}
|
|
1647
|
-
function transformMultiPoint(multiPoint, bbox2) {
|
|
1648
|
-
return getPoints(multiPoint, bbox2);
|
|
1649
|
-
}
|
|
1650
|
-
function transformLineString(line, bbox2) {
|
|
1651
|
-
return getPoints(line, bbox2);
|
|
1652
|
-
}
|
|
1653
|
-
function transformMultiLineString(multiLineString2, bbox2) {
|
|
1654
|
-
return multiLineString2.map(
|
|
1655
|
-
(lineString2) => transformLineString(lineString2, bbox2)
|
|
1656
|
-
);
|
|
1657
|
-
}
|
|
1658
|
-
function transformPolygon(polygon2, bbox2) {
|
|
1659
|
-
return polygon2.map((polygonRing) => getPoints(polygonRing, bbox2));
|
|
1660
|
-
}
|
|
1661
|
-
function transformMultiPolygon(multiPolygon2, bbox2) {
|
|
1662
|
-
return multiPolygon2.map((polygon2) => transformPolygon(polygon2, bbox2));
|
|
1663
|
-
}
|
|
1664
|
-
|
|
1665
1561
|
// node_modules/@turf/bbox-polygon/dist/esm/index.js
|
|
1666
1562
|
function bboxPolygon(bbox2, options = {}) {
|
|
1667
1563
|
const west = Number(bbox2[0]);
|
|
@@ -1980,7 +1876,7 @@ var MAX_SAFE_INTEGER = 9007199254740991;
|
|
|
1980
1876
|
var POWS_TEN = [1, 10, 100, 1e3, 1e4, 1e5, 1e6, 1e7, 1e8, 1e9, 1e10, 1e11, 1e12, 1e13];
|
|
1981
1877
|
var SQRT_BASE = 1e7;
|
|
1982
1878
|
var MAX = 1e9;
|
|
1983
|
-
function
|
|
1879
|
+
function clone(configObject) {
|
|
1984
1880
|
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 = {
|
|
1985
1881
|
prefix: "",
|
|
1986
1882
|
groupSize: 3,
|
|
@@ -2106,7 +2002,7 @@ function clone2(configObject) {
|
|
|
2106
2002
|
x.c = [x.e = 0];
|
|
2107
2003
|
}
|
|
2108
2004
|
}
|
|
2109
|
-
BigNumber2.clone =
|
|
2005
|
+
BigNumber2.clone = clone;
|
|
2110
2006
|
BigNumber2.ROUND_UP = 0;
|
|
2111
2007
|
BigNumber2.ROUND_DOWN = 1;
|
|
2112
2008
|
BigNumber2.ROUND_CEIL = 2;
|
|
@@ -3309,7 +3205,7 @@ function toFixedPoint(str, e, z) {
|
|
|
3309
3205
|
}
|
|
3310
3206
|
return str;
|
|
3311
3207
|
}
|
|
3312
|
-
var BigNumber =
|
|
3208
|
+
var BigNumber = clone();
|
|
3313
3209
|
var bignumber_default = BigNumber;
|
|
3314
3210
|
|
|
3315
3211
|
// node_modules/splaytree-ts/dist/esm/index.js
|
|
@@ -4879,7 +4775,117 @@ function intersect(features, options = {}) {
|
|
|
4879
4775
|
}
|
|
4880
4776
|
var turf_intersect_default = intersect;
|
|
4881
4777
|
|
|
4778
|
+
// node_modules/@math.gl/core/dist/lib/common.js
|
|
4779
|
+
var RADIANS_TO_DEGREES = 1 / Math.PI * 180;
|
|
4780
|
+
var DEGREES_TO_RADIANS = 1 / 180 * Math.PI;
|
|
4781
|
+
var DEFAULT_CONFIG = {
|
|
4782
|
+
EPSILON: 1e-12,
|
|
4783
|
+
debug: false,
|
|
4784
|
+
precision: 4,
|
|
4785
|
+
printTypes: false,
|
|
4786
|
+
printDegrees: false,
|
|
4787
|
+
printRowMajor: true,
|
|
4788
|
+
_cartographicRadians: false
|
|
4789
|
+
};
|
|
4790
|
+
globalThis.mathgl = globalThis.mathgl || { config: { ...DEFAULT_CONFIG } };
|
|
4791
|
+
var config = globalThis.mathgl.config;
|
|
4792
|
+
function isArray(value) {
|
|
4793
|
+
return Array.isArray(value) || ArrayBuffer.isView(value) && !(value instanceof DataView);
|
|
4794
|
+
}
|
|
4795
|
+
function lerp(a, b, t) {
|
|
4796
|
+
if (isArray(a)) {
|
|
4797
|
+
return a.map((ai, i) => lerp(ai, b[i], t));
|
|
4798
|
+
}
|
|
4799
|
+
return t * b + (1 - t) * a;
|
|
4800
|
+
}
|
|
4801
|
+
|
|
4802
|
+
// node_modules/@math.gl/web-mercator/dist/assert.js
|
|
4803
|
+
function assert(condition, message) {
|
|
4804
|
+
if (!condition) {
|
|
4805
|
+
throw new Error(message || "@math.gl/web-mercator: assertion failed.");
|
|
4806
|
+
}
|
|
4807
|
+
}
|
|
4808
|
+
|
|
4809
|
+
// node_modules/@math.gl/web-mercator/dist/web-mercator-utils.js
|
|
4810
|
+
var PI = Math.PI;
|
|
4811
|
+
var PI_4 = PI / 4;
|
|
4812
|
+
var DEGREES_TO_RADIANS2 = PI / 180;
|
|
4813
|
+
var RADIANS_TO_DEGREES2 = 180 / PI;
|
|
4814
|
+
var TILE_SIZE = 512;
|
|
4815
|
+
function lngLatToWorld(lngLat) {
|
|
4816
|
+
const [lng, lat] = lngLat;
|
|
4817
|
+
assert(Number.isFinite(lng));
|
|
4818
|
+
assert(Number.isFinite(lat) && lat >= -90 && lat <= 90, "invalid latitude");
|
|
4819
|
+
const lambda2 = lng * DEGREES_TO_RADIANS2;
|
|
4820
|
+
const phi2 = lat * DEGREES_TO_RADIANS2;
|
|
4821
|
+
const x = TILE_SIZE * (lambda2 + PI) / (2 * PI);
|
|
4822
|
+
const y = TILE_SIZE * (PI + Math.log(Math.tan(PI_4 + phi2 * 0.5))) / (2 * PI);
|
|
4823
|
+
return [x, y];
|
|
4824
|
+
}
|
|
4825
|
+
function worldToLngLat(xy) {
|
|
4826
|
+
const [x, y] = xy;
|
|
4827
|
+
const lambda2 = x / TILE_SIZE * (2 * PI) - PI;
|
|
4828
|
+
const phi2 = 2 * (Math.atan(Math.exp(y / TILE_SIZE * (2 * PI) - PI)) - PI_4);
|
|
4829
|
+
return [lambda2 * RADIANS_TO_DEGREES2, phi2 * RADIANS_TO_DEGREES2];
|
|
4830
|
+
}
|
|
4831
|
+
|
|
4832
|
+
// node_modules/@math.gl/web-mercator/dist/get-bounds.js
|
|
4833
|
+
var DEGREES_TO_RADIANS3 = Math.PI / 180;
|
|
4834
|
+
|
|
4882
4835
|
// src/utils/transformToTileCoords.ts
|
|
4836
|
+
var TRANSFORM_FN = {
|
|
4837
|
+
Point: transformPoint,
|
|
4838
|
+
MultiPoint: transformMultiPoint,
|
|
4839
|
+
LineString: transformLineString,
|
|
4840
|
+
MultiLineString: transformMultiLineString,
|
|
4841
|
+
Polygon: transformPolygon,
|
|
4842
|
+
MultiPolygon: transformMultiPolygon
|
|
4843
|
+
};
|
|
4844
|
+
function transformToTileCoords(geometry, bbox2) {
|
|
4845
|
+
const [west, south, east, north] = bbox2;
|
|
4846
|
+
const nw = projectFlat([west, north]);
|
|
4847
|
+
const se = projectFlat([east, south]);
|
|
4848
|
+
const projectedBbox = [nw, se];
|
|
4849
|
+
if (geometry.type === "GeometryCollection") {
|
|
4850
|
+
throw new Error("Unsupported geometry type GeometryCollection");
|
|
4851
|
+
}
|
|
4852
|
+
const transformFn = TRANSFORM_FN[geometry.type];
|
|
4853
|
+
const coordinates = transformFn(geometry.coordinates, projectedBbox);
|
|
4854
|
+
return { ...geometry, coordinates };
|
|
4855
|
+
}
|
|
4856
|
+
function transformPoint([pointX, pointY], [nw, se]) {
|
|
4857
|
+
const x = inverseLerp(nw[0], se[0], pointX);
|
|
4858
|
+
const y = inverseLerp(nw[1], se[1], pointY);
|
|
4859
|
+
return [x, y];
|
|
4860
|
+
}
|
|
4861
|
+
function getPoints(geometry, bbox2) {
|
|
4862
|
+
return geometry.map((g) => transformPoint(projectFlat(g), bbox2));
|
|
4863
|
+
}
|
|
4864
|
+
function transformMultiPoint(multiPoint, bbox2) {
|
|
4865
|
+
return getPoints(multiPoint, bbox2);
|
|
4866
|
+
}
|
|
4867
|
+
function transformLineString(line, bbox2) {
|
|
4868
|
+
return getPoints(line, bbox2);
|
|
4869
|
+
}
|
|
4870
|
+
function transformMultiLineString(multiLineString2, bbox2) {
|
|
4871
|
+
return multiLineString2.map(
|
|
4872
|
+
(lineString2) => transformLineString(lineString2, bbox2)
|
|
4873
|
+
);
|
|
4874
|
+
}
|
|
4875
|
+
function transformPolygon(polygon2, bbox2) {
|
|
4876
|
+
return polygon2.map((polygonRing) => getPoints(polygonRing, bbox2));
|
|
4877
|
+
}
|
|
4878
|
+
function transformMultiPolygon(multiPolygon2, bbox2) {
|
|
4879
|
+
return multiPolygon2.map((polygon2) => transformPolygon(polygon2, bbox2));
|
|
4880
|
+
}
|
|
4881
|
+
function projectFlat(xyz) {
|
|
4882
|
+
return lngLatToWorld(xyz);
|
|
4883
|
+
}
|
|
4884
|
+
function inverseLerp(a, b, x) {
|
|
4885
|
+
return (x - a) / (b - a);
|
|
4886
|
+
}
|
|
4887
|
+
|
|
4888
|
+
// src/utils/transformTileCoordsToWGS84.ts
|
|
4883
4889
|
var TRANSFORM_FN2 = {
|
|
4884
4890
|
Point: transformPoint2,
|
|
4885
4891
|
MultiPoint: transformMultiPoint2,
|
|
@@ -4888,10 +4894,10 @@ var TRANSFORM_FN2 = {
|
|
|
4888
4894
|
Polygon: transformPolygon2,
|
|
4889
4895
|
MultiPolygon: transformMultiPolygon2
|
|
4890
4896
|
};
|
|
4891
|
-
function
|
|
4897
|
+
function transformTileCoordsToWGS84(geometry, bbox2) {
|
|
4892
4898
|
const [west, south, east, north] = bbox2;
|
|
4893
|
-
const nw =
|
|
4894
|
-
const se =
|
|
4899
|
+
const nw = lngLatToWorld([west, north]);
|
|
4900
|
+
const se = lngLatToWorld([east, south]);
|
|
4895
4901
|
const projectedBbox = [nw, se];
|
|
4896
4902
|
if (geometry.type === "GeometryCollection") {
|
|
4897
4903
|
throw new Error("Unsupported geometry type GeometryCollection");
|
|
@@ -4901,12 +4907,12 @@ function transformToTileCoords(geometry, bbox2) {
|
|
|
4901
4907
|
return { ...geometry, coordinates };
|
|
4902
4908
|
}
|
|
4903
4909
|
function transformPoint2([pointX, pointY], [nw, se]) {
|
|
4904
|
-
const x =
|
|
4905
|
-
const y =
|
|
4906
|
-
return [x, y];
|
|
4910
|
+
const x = lerp(nw[0], se[0], pointX);
|
|
4911
|
+
const y = lerp(nw[1], se[1], pointY);
|
|
4912
|
+
return worldToLngLat([x, y]);
|
|
4907
4913
|
}
|
|
4908
4914
|
function getPoints2(geometry, bbox2) {
|
|
4909
|
-
return geometry.map((g) => transformPoint2(
|
|
4915
|
+
return geometry.map((g) => transformPoint2(g, bbox2));
|
|
4910
4916
|
}
|
|
4911
4917
|
function transformMultiPoint2(multiPoint, bbox2) {
|
|
4912
4918
|
return getPoints2(multiPoint, bbox2);
|
|
@@ -4925,203 +4931,6 @@ function transformPolygon2(polygon2, bbox2) {
|
|
|
4925
4931
|
function transformMultiPolygon2(multiPolygon2, bbox2) {
|
|
4926
4932
|
return multiPolygon2.map((polygon2) => transformPolygon2(polygon2, bbox2));
|
|
4927
4933
|
}
|
|
4928
|
-
function projectFlat(xyz) {
|
|
4929
|
-
return lngLatToWorld(xyz);
|
|
4930
|
-
}
|
|
4931
|
-
function inverseLerp(a, b, x) {
|
|
4932
|
-
return (x - a) / (b - a);
|
|
4933
|
-
}
|
|
4934
|
-
|
|
4935
|
-
// src/filters/tileIntersection.ts
|
|
4936
|
-
import {
|
|
4937
|
-
cellToBoundary as quadbinCellToBoundary,
|
|
4938
|
-
geometryToCells as quadbinGeometryToCells
|
|
4939
|
-
} from "quadbin";
|
|
4940
|
-
import {
|
|
4941
|
-
cellToBoundary as h3CellToBoundary,
|
|
4942
|
-
polygonToCells as h3PolygonToCells
|
|
4943
|
-
} from "h3-js";
|
|
4944
|
-
|
|
4945
|
-
// node_modules/@turf/bbox-clip/dist/esm/index.js
|
|
4946
|
-
function lineclip(points, bbox2, result) {
|
|
4947
|
-
var len = points.length, codeA = bitCode(points[0], bbox2), part = [], i, codeB, lastCode;
|
|
4948
|
-
let a;
|
|
4949
|
-
let b;
|
|
4950
|
-
if (!result) result = [];
|
|
4951
|
-
for (i = 1; i < len; i++) {
|
|
4952
|
-
a = points[i - 1];
|
|
4953
|
-
b = points[i];
|
|
4954
|
-
codeB = lastCode = bitCode(b, bbox2);
|
|
4955
|
-
while (true) {
|
|
4956
|
-
if (!(codeA | codeB)) {
|
|
4957
|
-
part.push(a);
|
|
4958
|
-
if (codeB !== lastCode) {
|
|
4959
|
-
part.push(b);
|
|
4960
|
-
if (i < len - 1) {
|
|
4961
|
-
result.push(part);
|
|
4962
|
-
part = [];
|
|
4963
|
-
}
|
|
4964
|
-
} else if (i === len - 1) {
|
|
4965
|
-
part.push(b);
|
|
4966
|
-
}
|
|
4967
|
-
break;
|
|
4968
|
-
} else if (codeA & codeB) {
|
|
4969
|
-
break;
|
|
4970
|
-
} else if (codeA) {
|
|
4971
|
-
a = intersect2(a, b, codeA, bbox2);
|
|
4972
|
-
codeA = bitCode(a, bbox2);
|
|
4973
|
-
} else {
|
|
4974
|
-
b = intersect2(a, b, codeB, bbox2);
|
|
4975
|
-
codeB = bitCode(b, bbox2);
|
|
4976
|
-
}
|
|
4977
|
-
}
|
|
4978
|
-
codeA = lastCode;
|
|
4979
|
-
}
|
|
4980
|
-
if (part.length) result.push(part);
|
|
4981
|
-
return result;
|
|
4982
|
-
}
|
|
4983
|
-
function polygonclip(points, bbox2) {
|
|
4984
|
-
var result, edge, prev, prevInside, i, p, inside;
|
|
4985
|
-
for (edge = 1; edge <= 8; edge *= 2) {
|
|
4986
|
-
result = [];
|
|
4987
|
-
prev = points[points.length - 1];
|
|
4988
|
-
prevInside = !(bitCode(prev, bbox2) & edge);
|
|
4989
|
-
for (i = 0; i < points.length; i++) {
|
|
4990
|
-
p = points[i];
|
|
4991
|
-
inside = !(bitCode(p, bbox2) & edge);
|
|
4992
|
-
if (inside !== prevInside) result.push(intersect2(prev, p, edge, bbox2));
|
|
4993
|
-
if (inside) result.push(p);
|
|
4994
|
-
prev = p;
|
|
4995
|
-
prevInside = inside;
|
|
4996
|
-
}
|
|
4997
|
-
points = result;
|
|
4998
|
-
if (!points.length) break;
|
|
4999
|
-
}
|
|
5000
|
-
return result;
|
|
5001
|
-
}
|
|
5002
|
-
function intersect2(a, b, edge, bbox2) {
|
|
5003
|
-
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;
|
|
5004
|
-
}
|
|
5005
|
-
function bitCode(p, bbox2) {
|
|
5006
|
-
var code = 0;
|
|
5007
|
-
if (p[0] < bbox2[0]) code |= 1;
|
|
5008
|
-
else if (p[0] > bbox2[2]) code |= 2;
|
|
5009
|
-
if (p[1] < bbox2[1]) code |= 4;
|
|
5010
|
-
else if (p[1] > bbox2[3]) code |= 8;
|
|
5011
|
-
return code;
|
|
5012
|
-
}
|
|
5013
|
-
function bboxClip(feature2, bbox2) {
|
|
5014
|
-
const geom = getGeom(feature2);
|
|
5015
|
-
const type = geom.type;
|
|
5016
|
-
const properties = feature2.type === "Feature" ? feature2.properties : {};
|
|
5017
|
-
let coords = geom.coordinates;
|
|
5018
|
-
switch (type) {
|
|
5019
|
-
case "LineString":
|
|
5020
|
-
case "MultiLineString": {
|
|
5021
|
-
const lines = [];
|
|
5022
|
-
if (type === "LineString") {
|
|
5023
|
-
coords = [coords];
|
|
5024
|
-
}
|
|
5025
|
-
coords.forEach((line) => {
|
|
5026
|
-
lineclip(line, bbox2, lines);
|
|
5027
|
-
});
|
|
5028
|
-
if (lines.length === 1) {
|
|
5029
|
-
return lineString(lines[0], properties);
|
|
5030
|
-
}
|
|
5031
|
-
return multiLineString(lines, properties);
|
|
5032
|
-
}
|
|
5033
|
-
case "Polygon":
|
|
5034
|
-
return polygon(clipPolygon(coords, bbox2), properties);
|
|
5035
|
-
case "MultiPolygon":
|
|
5036
|
-
return multiPolygon(
|
|
5037
|
-
coords.map((poly) => {
|
|
5038
|
-
return clipPolygon(poly, bbox2);
|
|
5039
|
-
}),
|
|
5040
|
-
properties
|
|
5041
|
-
);
|
|
5042
|
-
default:
|
|
5043
|
-
throw new Error("geometry " + type + " not supported");
|
|
5044
|
-
}
|
|
5045
|
-
}
|
|
5046
|
-
function clipPolygon(rings, bbox2) {
|
|
5047
|
-
const outRings = [];
|
|
5048
|
-
for (const ring of rings) {
|
|
5049
|
-
const clipped = polygonclip(ring, bbox2);
|
|
5050
|
-
if (clipped.length > 0) {
|
|
5051
|
-
if (clipped[0][0] !== clipped[clipped.length - 1][0] || clipped[0][1] !== clipped[clipped.length - 1][1]) {
|
|
5052
|
-
clipped.push(clipped[0]);
|
|
5053
|
-
}
|
|
5054
|
-
if (clipped.length >= 4) {
|
|
5055
|
-
outRings.push(clipped);
|
|
5056
|
-
}
|
|
5057
|
-
}
|
|
5058
|
-
}
|
|
5059
|
-
return outRings;
|
|
5060
|
-
}
|
|
5061
|
-
var turf_bbox_clip_default = bboxClip;
|
|
5062
|
-
|
|
5063
|
-
// src/filters/tileIntersection.ts
|
|
5064
|
-
function intersectTileGeometry(tileBbox, tileFormat, spatialFilter) {
|
|
5065
|
-
const tilePolygon = turf_bbox_polygon_default(tileBbox);
|
|
5066
|
-
if (!spatialFilter || turf_boolean_within_default(tilePolygon, spatialFilter)) {
|
|
5067
|
-
return true;
|
|
5068
|
-
}
|
|
5069
|
-
const clippedSpatialFilter = turf_intersect_default(
|
|
5070
|
-
featureCollection([tilePolygon, feature(spatialFilter)])
|
|
5071
|
-
);
|
|
5072
|
-
if (!clippedSpatialFilter) {
|
|
5073
|
-
return false;
|
|
5074
|
-
}
|
|
5075
|
-
return tileFormat === "mvt" /* MVT */ ? transformToTileCoords(clippedSpatialFilter.geometry, tileBbox) : clippedSpatialFilter.geometry;
|
|
5076
|
-
}
|
|
5077
|
-
function intersectTileRaster(parent, cellResolution, spatialFilter) {
|
|
5078
|
-
return intersectTileQuadbin(parent, cellResolution, spatialFilter);
|
|
5079
|
-
}
|
|
5080
|
-
function intersectTileQuadbin(parent, cellResolution, spatialFilter) {
|
|
5081
|
-
const tilePolygon = quadbinCellToBoundary(parent);
|
|
5082
|
-
if (!spatialFilter || turf_boolean_within_default(tilePolygon, spatialFilter)) {
|
|
5083
|
-
return true;
|
|
5084
|
-
}
|
|
5085
|
-
const clippedSpatialFilter = turf_intersect_default(
|
|
5086
|
-
featureCollection([feature(tilePolygon), feature(spatialFilter)])
|
|
5087
|
-
);
|
|
5088
|
-
if (!clippedSpatialFilter) {
|
|
5089
|
-
return false;
|
|
5090
|
-
}
|
|
5091
|
-
const cells = quadbinGeometryToCells(
|
|
5092
|
-
clippedSpatialFilter.geometry,
|
|
5093
|
-
cellResolution
|
|
5094
|
-
);
|
|
5095
|
-
return new Set(cells);
|
|
5096
|
-
}
|
|
5097
|
-
var BBOX_WEST = [-180, -90, 0, 90];
|
|
5098
|
-
var BBOX_EAST = [0, -90, 180, 90];
|
|
5099
|
-
function intersectTileH3(parent, cellResolution, spatialFilter) {
|
|
5100
|
-
const tilePolygon = {
|
|
5101
|
-
type: "Polygon",
|
|
5102
|
-
coordinates: [h3CellToBoundary(parent, true)]
|
|
5103
|
-
};
|
|
5104
|
-
if (!spatialFilter || turf_boolean_within_default(tilePolygon, spatialFilter)) {
|
|
5105
|
-
return true;
|
|
5106
|
-
}
|
|
5107
|
-
const clippedSpatialFilter = turf_intersect_default(
|
|
5108
|
-
featureCollection([feature(tilePolygon), feature(spatialFilter)])
|
|
5109
|
-
);
|
|
5110
|
-
if (!clippedSpatialFilter) {
|
|
5111
|
-
return false;
|
|
5112
|
-
}
|
|
5113
|
-
const cellsWest = h3PolygonToCells(
|
|
5114
|
-
turf_bbox_clip_default(clippedSpatialFilter, BBOX_WEST).geometry.coordinates,
|
|
5115
|
-
cellResolution,
|
|
5116
|
-
true
|
|
5117
|
-
);
|
|
5118
|
-
const cellsEast = h3PolygonToCells(
|
|
5119
|
-
turf_bbox_clip_default(clippedSpatialFilter, BBOX_EAST).geometry.coordinates,
|
|
5120
|
-
cellResolution,
|
|
5121
|
-
true
|
|
5122
|
-
);
|
|
5123
|
-
return new Set(cellsWest.concat(cellsEast));
|
|
5124
|
-
}
|
|
5125
4934
|
|
|
5126
4935
|
// src/filters/tileFeaturesGeometries.ts
|
|
5127
4936
|
var FEATURE_GEOM_PROPERTY = "__geomValue";
|
|
@@ -5137,45 +4946,55 @@ function tileFeaturesGeometries({
|
|
|
5137
4946
|
if (tile.isVisible === false || !tile.data) {
|
|
5138
4947
|
continue;
|
|
5139
4948
|
}
|
|
5140
|
-
const
|
|
4949
|
+
const bbox2 = [
|
|
5141
4950
|
tile.bbox.west,
|
|
5142
4951
|
tile.bbox.south,
|
|
5143
4952
|
tile.bbox.east,
|
|
5144
4953
|
tile.bbox.north
|
|
5145
4954
|
];
|
|
5146
|
-
const
|
|
5147
|
-
|
|
5148
|
-
|
|
5149
|
-
|
|
4955
|
+
const bboxToGeom = turf_bbox_polygon_default(bbox2);
|
|
4956
|
+
const tileIsFullyVisible = turf_boolean_within_default(bboxToGeom, spatialFilter);
|
|
4957
|
+
const spatialFilterFeature = {
|
|
4958
|
+
type: "Feature",
|
|
4959
|
+
geometry: spatialFilter,
|
|
4960
|
+
properties: {}
|
|
4961
|
+
};
|
|
4962
|
+
const clippedGeometryToIntersect = turf_intersect_default(
|
|
4963
|
+
featureCollection([bboxToGeom, spatialFilterFeature])
|
|
5150
4964
|
);
|
|
5151
|
-
if (
|
|
5152
|
-
|
|
4965
|
+
if (!clippedGeometryToIntersect) {
|
|
4966
|
+
continue;
|
|
4967
|
+
}
|
|
4968
|
+
const transformedGeometryToIntersect = tileFormat === "mvt" /* MVT */ ? transformToTileCoords(clippedGeometryToIntersect.geometry, bbox2) : clippedGeometryToIntersect.geometry;
|
|
5153
4969
|
calculateFeatures({
|
|
5154
4970
|
map,
|
|
5155
|
-
|
|
4971
|
+
tileIsFullyVisible,
|
|
4972
|
+
geometryIntersection: transformedGeometryToIntersect,
|
|
5156
4973
|
data: tile.data.points,
|
|
5157
4974
|
type: "Point",
|
|
5158
|
-
bbox:
|
|
4975
|
+
bbox: bbox2,
|
|
5159
4976
|
tileFormat,
|
|
5160
4977
|
uniqueIdProperty,
|
|
5161
4978
|
options
|
|
5162
4979
|
});
|
|
5163
4980
|
calculateFeatures({
|
|
5164
4981
|
map,
|
|
5165
|
-
|
|
4982
|
+
tileIsFullyVisible,
|
|
4983
|
+
geometryIntersection: transformedGeometryToIntersect,
|
|
5166
4984
|
data: tile.data.lines,
|
|
5167
4985
|
type: "LineString",
|
|
5168
|
-
bbox:
|
|
4986
|
+
bbox: bbox2,
|
|
5169
4987
|
tileFormat,
|
|
5170
4988
|
uniqueIdProperty,
|
|
5171
4989
|
options
|
|
5172
4990
|
});
|
|
5173
4991
|
calculateFeatures({
|
|
5174
4992
|
map,
|
|
5175
|
-
|
|
4993
|
+
tileIsFullyVisible,
|
|
4994
|
+
geometryIntersection: transformedGeometryToIntersect,
|
|
5176
4995
|
data: tile.data.polygons,
|
|
5177
4996
|
type: "Polygon",
|
|
5178
|
-
bbox:
|
|
4997
|
+
bbox: bbox2,
|
|
5179
4998
|
tileFormat,
|
|
5180
4999
|
uniqueIdProperty,
|
|
5181
5000
|
options
|
|
@@ -5193,7 +5012,7 @@ function processTileFeatureProperties({
|
|
|
5193
5012
|
tileFormat,
|
|
5194
5013
|
uniqueIdProperty,
|
|
5195
5014
|
storeGeometry,
|
|
5196
|
-
|
|
5015
|
+
geometryIntersection
|
|
5197
5016
|
}) {
|
|
5198
5017
|
const tileProps = getPropertiesFromTile(data, startIndex);
|
|
5199
5018
|
const uniquePropertyValue = getUniquePropertyValue(
|
|
@@ -5205,7 +5024,7 @@ function processTileFeatureProperties({
|
|
|
5205
5024
|
return;
|
|
5206
5025
|
}
|
|
5207
5026
|
let geometry = null;
|
|
5208
|
-
if (storeGeometry ||
|
|
5027
|
+
if (storeGeometry || geometryIntersection) {
|
|
5209
5028
|
const { positions } = data;
|
|
5210
5029
|
const ringCoordinates = getRingCoordinatesFor(
|
|
5211
5030
|
startIndex,
|
|
@@ -5214,7 +5033,7 @@ function processTileFeatureProperties({
|
|
|
5214
5033
|
);
|
|
5215
5034
|
geometry = getFeatureByType(ringCoordinates, type);
|
|
5216
5035
|
}
|
|
5217
|
-
if (geometry &&
|
|
5036
|
+
if (geometry && geometryIntersection && !turf_boolean_intersects_default(geometry, geometryIntersection)) {
|
|
5218
5037
|
return;
|
|
5219
5038
|
}
|
|
5220
5039
|
const properties = parseProperties(tileProps);
|
|
@@ -5226,7 +5045,7 @@ function processTileFeatureProperties({
|
|
|
5226
5045
|
function addIntersectedFeaturesInTile({
|
|
5227
5046
|
map,
|
|
5228
5047
|
data,
|
|
5229
|
-
|
|
5048
|
+
geometryIntersection,
|
|
5230
5049
|
type,
|
|
5231
5050
|
bbox: bbox2,
|
|
5232
5051
|
tileFormat,
|
|
@@ -5248,7 +5067,7 @@ function addIntersectedFeaturesInTile({
|
|
|
5248
5067
|
tileFormat,
|
|
5249
5068
|
uniqueIdProperty,
|
|
5250
5069
|
storeGeometry,
|
|
5251
|
-
|
|
5070
|
+
geometryIntersection
|
|
5252
5071
|
});
|
|
5253
5072
|
}
|
|
5254
5073
|
}
|
|
@@ -5330,7 +5149,8 @@ function getRingCoordinatesFor(startIndex, endIndex, positions) {
|
|
|
5330
5149
|
}
|
|
5331
5150
|
function calculateFeatures({
|
|
5332
5151
|
map,
|
|
5333
|
-
|
|
5152
|
+
tileIsFullyVisible,
|
|
5153
|
+
geometryIntersection,
|
|
5334
5154
|
data,
|
|
5335
5155
|
type,
|
|
5336
5156
|
bbox: bbox2,
|
|
@@ -5341,7 +5161,7 @@ function calculateFeatures({
|
|
|
5341
5161
|
if (!data?.properties.length) {
|
|
5342
5162
|
return;
|
|
5343
5163
|
}
|
|
5344
|
-
if (
|
|
5164
|
+
if (tileIsFullyVisible) {
|
|
5345
5165
|
addAllFeaturesInTile({
|
|
5346
5166
|
map,
|
|
5347
5167
|
data,
|
|
@@ -5355,7 +5175,7 @@ function calculateFeatures({
|
|
|
5355
5175
|
addIntersectedFeaturesInTile({
|
|
5356
5176
|
map,
|
|
5357
5177
|
data,
|
|
5358
|
-
|
|
5178
|
+
geometryIntersection,
|
|
5359
5179
|
type,
|
|
5360
5180
|
bbox: bbox2,
|
|
5361
5181
|
tileFormat,
|
|
@@ -5405,8 +5225,128 @@ function createIndicesForPoints(data) {
|
|
|
5405
5225
|
}
|
|
5406
5226
|
|
|
5407
5227
|
// src/filters/tileFeaturesSpatialIndex.ts
|
|
5408
|
-
import { getResolution as quadbinGetResolution } from "quadbin";
|
|
5409
|
-
|
|
5228
|
+
import { getResolution as quadbinGetResolution, geometryToCells } from "quadbin";
|
|
5229
|
+
|
|
5230
|
+
// node_modules/@turf/bbox-clip/dist/esm/index.js
|
|
5231
|
+
function lineclip(points, bbox2, result) {
|
|
5232
|
+
var len = points.length, codeA = bitCode(points[0], bbox2), part = [], i, codeB, lastCode;
|
|
5233
|
+
let a;
|
|
5234
|
+
let b;
|
|
5235
|
+
if (!result) result = [];
|
|
5236
|
+
for (i = 1; i < len; i++) {
|
|
5237
|
+
a = points[i - 1];
|
|
5238
|
+
b = points[i];
|
|
5239
|
+
codeB = lastCode = bitCode(b, bbox2);
|
|
5240
|
+
while (true) {
|
|
5241
|
+
if (!(codeA | codeB)) {
|
|
5242
|
+
part.push(a);
|
|
5243
|
+
if (codeB !== lastCode) {
|
|
5244
|
+
part.push(b);
|
|
5245
|
+
if (i < len - 1) {
|
|
5246
|
+
result.push(part);
|
|
5247
|
+
part = [];
|
|
5248
|
+
}
|
|
5249
|
+
} else if (i === len - 1) {
|
|
5250
|
+
part.push(b);
|
|
5251
|
+
}
|
|
5252
|
+
break;
|
|
5253
|
+
} else if (codeA & codeB) {
|
|
5254
|
+
break;
|
|
5255
|
+
} else if (codeA) {
|
|
5256
|
+
a = intersect2(a, b, codeA, bbox2);
|
|
5257
|
+
codeA = bitCode(a, bbox2);
|
|
5258
|
+
} else {
|
|
5259
|
+
b = intersect2(a, b, codeB, bbox2);
|
|
5260
|
+
codeB = bitCode(b, bbox2);
|
|
5261
|
+
}
|
|
5262
|
+
}
|
|
5263
|
+
codeA = lastCode;
|
|
5264
|
+
}
|
|
5265
|
+
if (part.length) result.push(part);
|
|
5266
|
+
return result;
|
|
5267
|
+
}
|
|
5268
|
+
function polygonclip(points, bbox2) {
|
|
5269
|
+
var result, edge, prev, prevInside, i, p, inside;
|
|
5270
|
+
for (edge = 1; edge <= 8; edge *= 2) {
|
|
5271
|
+
result = [];
|
|
5272
|
+
prev = points[points.length - 1];
|
|
5273
|
+
prevInside = !(bitCode(prev, bbox2) & edge);
|
|
5274
|
+
for (i = 0; i < points.length; i++) {
|
|
5275
|
+
p = points[i];
|
|
5276
|
+
inside = !(bitCode(p, bbox2) & edge);
|
|
5277
|
+
if (inside !== prevInside) result.push(intersect2(prev, p, edge, bbox2));
|
|
5278
|
+
if (inside) result.push(p);
|
|
5279
|
+
prev = p;
|
|
5280
|
+
prevInside = inside;
|
|
5281
|
+
}
|
|
5282
|
+
points = result;
|
|
5283
|
+
if (!points.length) break;
|
|
5284
|
+
}
|
|
5285
|
+
return result;
|
|
5286
|
+
}
|
|
5287
|
+
function intersect2(a, b, edge, bbox2) {
|
|
5288
|
+
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;
|
|
5289
|
+
}
|
|
5290
|
+
function bitCode(p, bbox2) {
|
|
5291
|
+
var code = 0;
|
|
5292
|
+
if (p[0] < bbox2[0]) code |= 1;
|
|
5293
|
+
else if (p[0] > bbox2[2]) code |= 2;
|
|
5294
|
+
if (p[1] < bbox2[1]) code |= 4;
|
|
5295
|
+
else if (p[1] > bbox2[3]) code |= 8;
|
|
5296
|
+
return code;
|
|
5297
|
+
}
|
|
5298
|
+
function bboxClip(feature2, bbox2) {
|
|
5299
|
+
const geom = getGeom(feature2);
|
|
5300
|
+
const type = geom.type;
|
|
5301
|
+
const properties = feature2.type === "Feature" ? feature2.properties : {};
|
|
5302
|
+
let coords = geom.coordinates;
|
|
5303
|
+
switch (type) {
|
|
5304
|
+
case "LineString":
|
|
5305
|
+
case "MultiLineString": {
|
|
5306
|
+
const lines = [];
|
|
5307
|
+
if (type === "LineString") {
|
|
5308
|
+
coords = [coords];
|
|
5309
|
+
}
|
|
5310
|
+
coords.forEach((line) => {
|
|
5311
|
+
lineclip(line, bbox2, lines);
|
|
5312
|
+
});
|
|
5313
|
+
if (lines.length === 1) {
|
|
5314
|
+
return lineString(lines[0], properties);
|
|
5315
|
+
}
|
|
5316
|
+
return multiLineString(lines, properties);
|
|
5317
|
+
}
|
|
5318
|
+
case "Polygon":
|
|
5319
|
+
return polygon(clipPolygon(coords, bbox2), properties);
|
|
5320
|
+
case "MultiPolygon":
|
|
5321
|
+
return multiPolygon(
|
|
5322
|
+
coords.map((poly) => {
|
|
5323
|
+
return clipPolygon(poly, bbox2);
|
|
5324
|
+
}),
|
|
5325
|
+
properties
|
|
5326
|
+
);
|
|
5327
|
+
default:
|
|
5328
|
+
throw new Error("geometry " + type + " not supported");
|
|
5329
|
+
}
|
|
5330
|
+
}
|
|
5331
|
+
function clipPolygon(rings, bbox2) {
|
|
5332
|
+
const outRings = [];
|
|
5333
|
+
for (const ring of rings) {
|
|
5334
|
+
const clipped = polygonclip(ring, bbox2);
|
|
5335
|
+
if (clipped.length > 0) {
|
|
5336
|
+
if (clipped[0][0] !== clipped[clipped.length - 1][0] || clipped[0][1] !== clipped[clipped.length - 1][1]) {
|
|
5337
|
+
clipped.push(clipped[0]);
|
|
5338
|
+
}
|
|
5339
|
+
if (clipped.length >= 4) {
|
|
5340
|
+
outRings.push(clipped);
|
|
5341
|
+
}
|
|
5342
|
+
}
|
|
5343
|
+
}
|
|
5344
|
+
return outRings;
|
|
5345
|
+
}
|
|
5346
|
+
var turf_bbox_clip_default = bboxClip;
|
|
5347
|
+
|
|
5348
|
+
// src/filters/tileFeaturesSpatialIndex.ts
|
|
5349
|
+
import { getResolution as h3GetResolution, polygonToCells } from "h3-js";
|
|
5410
5350
|
function tileFeaturesSpatialIndex({
|
|
5411
5351
|
tiles,
|
|
5412
5352
|
spatialFilter,
|
|
@@ -5415,40 +5355,28 @@ function tileFeaturesSpatialIndex({
|
|
|
5415
5355
|
}) {
|
|
5416
5356
|
const map = /* @__PURE__ */ new Map();
|
|
5417
5357
|
const spatialIndex = getSpatialIndex(spatialDataType);
|
|
5418
|
-
const
|
|
5358
|
+
const resolution = getResolution(tiles, spatialIndex);
|
|
5419
5359
|
const spatialIndexIDName = spatialDataColumn ? spatialDataColumn : spatialIndex;
|
|
5420
|
-
if (!
|
|
5360
|
+
if (!resolution) {
|
|
5361
|
+
return [];
|
|
5362
|
+
}
|
|
5363
|
+
const cells = getCellsCoverGeometry(spatialFilter, spatialIndex, resolution);
|
|
5364
|
+
if (!cells?.length) {
|
|
5421
5365
|
return [];
|
|
5422
5366
|
}
|
|
5367
|
+
const cellsSet = new Set(cells);
|
|
5423
5368
|
for (const tile of tiles) {
|
|
5424
5369
|
if (tile.isVisible === false || !tile.data) {
|
|
5425
5370
|
continue;
|
|
5426
5371
|
}
|
|
5427
|
-
const parent = getTileIndex(tile, spatialIndex);
|
|
5428
|
-
const intersection3 = spatialIndex === "quadbin" /* QUADBIN */ ? intersectTileQuadbin(
|
|
5429
|
-
parent,
|
|
5430
|
-
cellResolution,
|
|
5431
|
-
spatialFilter
|
|
5432
|
-
) : intersectTileH3(
|
|
5433
|
-
parent,
|
|
5434
|
-
cellResolution,
|
|
5435
|
-
spatialFilter
|
|
5436
|
-
);
|
|
5437
|
-
if (!intersection3) continue;
|
|
5438
5372
|
tile.data.forEach((d) => {
|
|
5439
|
-
if (
|
|
5373
|
+
if (cellsSet.has(d.id)) {
|
|
5440
5374
|
map.set(d.id, { ...d.properties, [spatialIndexIDName]: d.id });
|
|
5441
5375
|
}
|
|
5442
5376
|
});
|
|
5443
5377
|
}
|
|
5444
5378
|
return Array.from(map.values());
|
|
5445
5379
|
}
|
|
5446
|
-
function getTileIndex(tile, spatialIndex) {
|
|
5447
|
-
if (spatialIndex === "quadbin" /* QUADBIN */) {
|
|
5448
|
-
return tile.index.q;
|
|
5449
|
-
}
|
|
5450
|
-
return tile.id;
|
|
5451
|
-
}
|
|
5452
5380
|
function getResolution(tiles, spatialIndex) {
|
|
5453
5381
|
const data = tiles.find((tile) => tile.data?.length)?.data;
|
|
5454
5382
|
if (!data) {
|
|
@@ -5461,6 +5389,26 @@ function getResolution(tiles, spatialIndex) {
|
|
|
5461
5389
|
return h3GetResolution(data[0].id);
|
|
5462
5390
|
}
|
|
5463
5391
|
}
|
|
5392
|
+
var bboxWest = [-180, -90, 0, 90];
|
|
5393
|
+
var bboxEast = [0, -90, 180, 90];
|
|
5394
|
+
function getCellsCoverGeometry(geometry, spatialIndex, resolution) {
|
|
5395
|
+
if (spatialIndex === "quadbin" /* QUADBIN */) {
|
|
5396
|
+
return geometryToCells(geometry, resolution);
|
|
5397
|
+
}
|
|
5398
|
+
if (spatialIndex === "h3" /* H3 */) {
|
|
5399
|
+
return polygonToCells(
|
|
5400
|
+
turf_bbox_clip_default(geometry, bboxWest).geometry.coordinates,
|
|
5401
|
+
resolution,
|
|
5402
|
+
true
|
|
5403
|
+
).concat(
|
|
5404
|
+
polygonToCells(
|
|
5405
|
+
turf_bbox_clip_default(geometry, bboxEast).geometry.coordinates,
|
|
5406
|
+
resolution,
|
|
5407
|
+
true
|
|
5408
|
+
)
|
|
5409
|
+
);
|
|
5410
|
+
}
|
|
5411
|
+
}
|
|
5464
5412
|
function getSpatialIndex(spatialDataType) {
|
|
5465
5413
|
switch (spatialDataType) {
|
|
5466
5414
|
case "h3":
|
|
@@ -5486,7 +5434,9 @@ var DEFAULT_AGGREGATION_EXP = `1 AS ${DEFAULT_AGGREGATION_EXP_ALIAS}`;
|
|
|
5486
5434
|
// src/filters/tileFeaturesRaster.ts
|
|
5487
5435
|
import {
|
|
5488
5436
|
cellToChildren as _cellToChildren,
|
|
5437
|
+
cellToBoundary,
|
|
5489
5438
|
cellToTile,
|
|
5439
|
+
geometryToCells as geometryToCells2,
|
|
5490
5440
|
getResolution as getResolution2
|
|
5491
5441
|
} from "quadbin";
|
|
5492
5442
|
function tileFeaturesRaster({
|
|
@@ -5505,15 +5455,15 @@ function tileFeaturesRaster({
|
|
|
5505
5455
|
const data = /* @__PURE__ */ new Map();
|
|
5506
5456
|
for (const tile of tiles) {
|
|
5507
5457
|
const parent = tile.index.q;
|
|
5508
|
-
const
|
|
5509
|
-
|
|
5510
|
-
|
|
5511
|
-
options.spatialFilter
|
|
5458
|
+
const tilePolygon = cellToBoundary(parent);
|
|
5459
|
+
const tileFilter = turf_intersect_default(
|
|
5460
|
+
featureCollection([feature(tilePolygon), feature(options.spatialFilter)])
|
|
5512
5461
|
);
|
|
5513
|
-
|
|
5462
|
+
const needsFilter = tileFilter ? !turf_boolean_within_default(tilePolygon, options.spatialFilter) : false;
|
|
5463
|
+
const tileFilterCells = needsFilter ? new Set(geometryToCells2(tileFilter.geometry, cellResolution)) : null;
|
|
5514
5464
|
const tileSortedCells = cellToChildrenSorted(parent, cellResolution);
|
|
5515
5465
|
for (let i = 0; i < tileSortedCells.length; i++) {
|
|
5516
|
-
if (
|
|
5466
|
+
if (needsFilter && !tileFilterCells.has(tileSortedCells[i])) {
|
|
5517
5467
|
continue;
|
|
5518
5468
|
}
|
|
5519
5469
|
const cellData = {};
|
|
@@ -6302,6 +6252,9 @@ function getApplicableFilters(owner, filters) {
|
|
|
6302
6252
|
return applicableFilters;
|
|
6303
6253
|
}
|
|
6304
6254
|
|
|
6255
|
+
// src/widget-sources/constants.ts
|
|
6256
|
+
var OTHERS_CATEGORY_NAME = "_carto_others";
|
|
6257
|
+
|
|
6305
6258
|
// src/widget-sources/widget-remote-source.ts
|
|
6306
6259
|
var WidgetRemoteSource = class extends WidgetSource {
|
|
6307
6260
|
_getModelSource(filters, filterOwner) {
|
|
@@ -6325,13 +6278,21 @@ var WidgetRemoteSource = class extends WidgetSource {
|
|
|
6325
6278
|
filterOwner,
|
|
6326
6279
|
spatialFilter,
|
|
6327
6280
|
spatialFiltersMode,
|
|
6281
|
+
rawResult,
|
|
6328
6282
|
...params
|
|
6329
6283
|
} = options;
|
|
6330
|
-
const {
|
|
6284
|
+
const {
|
|
6285
|
+
column,
|
|
6286
|
+
operation: operation2,
|
|
6287
|
+
operationColumn,
|
|
6288
|
+
operationExp,
|
|
6289
|
+
othersThreshold,
|
|
6290
|
+
orderBy
|
|
6291
|
+
} = params;
|
|
6331
6292
|
if (operation2 === AggregationTypes.Custom) {
|
|
6332
6293
|
assert2(operationExp, "operationExp is required for custom operation");
|
|
6333
6294
|
}
|
|
6334
|
-
|
|
6295
|
+
const result = await executeModel({
|
|
6335
6296
|
model: "category",
|
|
6336
6297
|
source: {
|
|
6337
6298
|
...this.getModelSource(filters, filterOwner),
|
|
@@ -6342,10 +6303,23 @@ var WidgetRemoteSource = class extends WidgetSource {
|
|
|
6342
6303
|
column,
|
|
6343
6304
|
operation: operation2,
|
|
6344
6305
|
operationExp,
|
|
6345
|
-
operationColumn: operationColumn || column
|
|
6306
|
+
operationColumn: operationColumn || column,
|
|
6307
|
+
othersThreshold,
|
|
6308
|
+
orderBy
|
|
6346
6309
|
},
|
|
6347
6310
|
opts: { signal, headers: this.props.headers }
|
|
6348
|
-
})
|
|
6311
|
+
});
|
|
6312
|
+
const normalizedRows = normalizeObjectKeys(result.rows || []);
|
|
6313
|
+
if (rawResult) {
|
|
6314
|
+
return result;
|
|
6315
|
+
}
|
|
6316
|
+
if (!othersThreshold) {
|
|
6317
|
+
return normalizedRows;
|
|
6318
|
+
}
|
|
6319
|
+
return [
|
|
6320
|
+
...normalizedRows,
|
|
6321
|
+
{ name: OTHERS_CATEGORY_NAME, value: result?.metadata?.others }
|
|
6322
|
+
];
|
|
6349
6323
|
}
|
|
6350
6324
|
async getFeatures(options) {
|
|
6351
6325
|
const {
|
|
@@ -6738,10 +6712,12 @@ function groupValuesByColumn({
|
|
|
6738
6712
|
valuesColumns,
|
|
6739
6713
|
joinOperation,
|
|
6740
6714
|
keysColumn,
|
|
6741
|
-
operation: operation2
|
|
6715
|
+
operation: operation2,
|
|
6716
|
+
othersThreshold,
|
|
6717
|
+
orderBy = "frequency_desc"
|
|
6742
6718
|
}) {
|
|
6743
6719
|
if (Array.isArray(data) && data.length === 0) {
|
|
6744
|
-
return null;
|
|
6720
|
+
return { rows: null };
|
|
6745
6721
|
}
|
|
6746
6722
|
const groups = data.reduce((accumulator, item) => {
|
|
6747
6723
|
const group2 = item[keysColumn];
|
|
@@ -6756,13 +6732,44 @@ function groupValuesByColumn({
|
|
|
6756
6732
|
return accumulator;
|
|
6757
6733
|
}, /* @__PURE__ */ new Map());
|
|
6758
6734
|
const targetOperation = aggregationFunctions[operation2];
|
|
6759
|
-
if (targetOperation) {
|
|
6760
|
-
return
|
|
6761
|
-
|
|
6762
|
-
|
|
6763
|
-
|
|
6735
|
+
if (!targetOperation) {
|
|
6736
|
+
return { rows: [] };
|
|
6737
|
+
}
|
|
6738
|
+
const allCategories = Array.from(groups).map(([name, value]) => ({
|
|
6739
|
+
name,
|
|
6740
|
+
value: targetOperation(value)
|
|
6741
|
+
})).sort(getSorter(orderBy));
|
|
6742
|
+
if (othersThreshold && allCategories.length > othersThreshold) {
|
|
6743
|
+
const otherValue = allCategories.slice(othersThreshold).flatMap(({ name }) => groups.get(name));
|
|
6744
|
+
allCategories.push({
|
|
6745
|
+
name: OTHERS_CATEGORY_NAME,
|
|
6746
|
+
value: targetOperation(otherValue)
|
|
6747
|
+
});
|
|
6748
|
+
return {
|
|
6749
|
+
rows: allCategories,
|
|
6750
|
+
metadata: {
|
|
6751
|
+
others: targetOperation(otherValue)
|
|
6752
|
+
}
|
|
6753
|
+
};
|
|
6764
6754
|
}
|
|
6765
|
-
return
|
|
6755
|
+
return {
|
|
6756
|
+
rows: allCategories
|
|
6757
|
+
};
|
|
6758
|
+
}
|
|
6759
|
+
function getSorter(orderBy) {
|
|
6760
|
+
switch (orderBy) {
|
|
6761
|
+
case "frequency_asc":
|
|
6762
|
+
return (a, b) => a.value - b.value || localeCompare(a.name, b.name);
|
|
6763
|
+
case "frequency_desc":
|
|
6764
|
+
return (a, b) => b.value - a.value || localeCompare(a.name, b.name);
|
|
6765
|
+
case "alphabetical_asc":
|
|
6766
|
+
return (a, b) => localeCompare(a.name, b.name) || b.value - a.value;
|
|
6767
|
+
case "alphabetical_desc":
|
|
6768
|
+
return (a, b) => localeCompare(b.name, a.name) || b.value - a.value;
|
|
6769
|
+
}
|
|
6770
|
+
}
|
|
6771
|
+
function localeCompare(a, b) {
|
|
6772
|
+
return (a ?? "null").localeCompare(b ?? "null");
|
|
6766
6773
|
}
|
|
6767
6774
|
|
|
6768
6775
|
// src/utils/dateUtils.ts
|
|
@@ -7236,7 +7243,7 @@ var WidgetTilesetSourceImpl = class extends WidgetSource {
|
|
|
7236
7243
|
}
|
|
7237
7244
|
_extractTileFeatures(spatialFilter) {
|
|
7238
7245
|
const prevInputs = this._tileFeatureExtractPreviousInputs;
|
|
7239
|
-
if (this._features.length &&
|
|
7246
|
+
if (this._features.length && prevInputs.spatialFilter && booleanEqual(prevInputs.spatialFilter, spatialFilter)) {
|
|
7240
7247
|
return;
|
|
7241
7248
|
}
|
|
7242
7249
|
this._features = tileFeatures({
|
|
@@ -7325,7 +7332,10 @@ var WidgetTilesetSourceImpl = class extends WidgetSource {
|
|
|
7325
7332
|
joinOperation,
|
|
7326
7333
|
filters,
|
|
7327
7334
|
filterOwner,
|
|
7328
|
-
spatialFilter
|
|
7335
|
+
spatialFilter,
|
|
7336
|
+
othersThreshold,
|
|
7337
|
+
orderBy = "frequency_desc",
|
|
7338
|
+
rawResult
|
|
7329
7339
|
}) {
|
|
7330
7340
|
const filteredFeatures = this._getFilteredFeatures(
|
|
7331
7341
|
spatialFilter,
|
|
@@ -7336,14 +7346,25 @@ var WidgetTilesetSourceImpl = class extends WidgetSource {
|
|
|
7336
7346
|
return [];
|
|
7337
7347
|
}
|
|
7338
7348
|
assertColumn(this._features, column, operationColumn);
|
|
7339
|
-
const
|
|
7349
|
+
const result = groupValuesByColumn({
|
|
7340
7350
|
data: filteredFeatures,
|
|
7341
7351
|
valuesColumns: normalizeColumns(operationColumn || column),
|
|
7342
7352
|
joinOperation,
|
|
7343
7353
|
keysColumn: column,
|
|
7344
|
-
operation: operation2
|
|
7354
|
+
operation: operation2,
|
|
7355
|
+
othersThreshold,
|
|
7356
|
+
orderBy
|
|
7345
7357
|
});
|
|
7346
|
-
|
|
7358
|
+
if (rawResult) {
|
|
7359
|
+
return result;
|
|
7360
|
+
}
|
|
7361
|
+
if (!othersThreshold) {
|
|
7362
|
+
return result?.rows || [];
|
|
7363
|
+
}
|
|
7364
|
+
return [
|
|
7365
|
+
...result?.rows || [],
|
|
7366
|
+
{ name: OTHERS_CATEGORY_NAME, value: result?.metadata?.others }
|
|
7367
|
+
];
|
|
7347
7368
|
}
|
|
7348
7369
|
async getScatter({
|
|
7349
7370
|
xAxisColumn,
|
|
@@ -7476,6 +7497,7 @@ var WidgetTilesetSourceImpl = class extends WidgetSource {
|
|
|
7476
7497
|
* INTERNAL
|
|
7477
7498
|
*/
|
|
7478
7499
|
_getFilteredFeatures(spatialFilter, filters, filterOwner) {
|
|
7500
|
+
assert2(spatialFilter, "spatialFilter required for tilesets");
|
|
7479
7501
|
this._extractTileFeatures(spatialFilter);
|
|
7480
7502
|
return applyFilters(
|
|
7481
7503
|
this._features,
|
|
@@ -7499,11 +7521,6 @@ function assertColumn(features, ...columnArgs) {
|
|
|
7499
7521
|
function normalizeColumns(columns) {
|
|
7500
7522
|
return Array.isArray(columns) ? columns : typeof columns === "string" ? [columns] : [];
|
|
7501
7523
|
}
|
|
7502
|
-
function spatialFilterEquals(a, b) {
|
|
7503
|
-
if (a === b) return true;
|
|
7504
|
-
if (!a || !b) return false;
|
|
7505
|
-
return booleanEqual(a, b);
|
|
7506
|
-
}
|
|
7507
7524
|
|
|
7508
7525
|
// src/widget-sources/widget-tileset-source.ts
|
|
7509
7526
|
var WidgetTilesetSource = class extends WidgetSource {
|
|
@@ -10089,6 +10106,7 @@ export {
|
|
|
10089
10106
|
FEATURE_GEOM_PROPERTY,
|
|
10090
10107
|
FilterType,
|
|
10091
10108
|
OPACITY_MAP,
|
|
10109
|
+
OTHERS_CATEGORY_NAME,
|
|
10092
10110
|
Provider,
|
|
10093
10111
|
SOURCE_DEFAULTS,
|
|
10094
10112
|
SchemaFieldType,
|
|
@@ -10139,6 +10157,7 @@ export {
|
|
|
10139
10157
|
getLayerProps,
|
|
10140
10158
|
getMaxMarkerSize,
|
|
10141
10159
|
getSizeAccessor,
|
|
10160
|
+
getSorter,
|
|
10142
10161
|
getSpatialIndexFromGeoColumn,
|
|
10143
10162
|
getTextAccessor,
|
|
10144
10163
|
groupValuesByColumn,
|