@carto/api-client 0.5.7-alpha-optional-spatial-filter.1 → 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 +436 -406
- 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 +400 -371
- package/build/api-client.js.map +1 -1
- package/build/worker-compat.js +865 -856
- package/build/worker-compat.js.map +1 -1
- package/build/worker.js +373 -367
- 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 +50 -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 -155
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,191 +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 { polygonToCells as h3PolygonToCells } from "h3-js";
|
|
4941
|
-
|
|
4942
|
-
// node_modules/@turf/bbox-clip/dist/esm/index.js
|
|
4943
|
-
function lineclip(points, bbox2, result) {
|
|
4944
|
-
var len = points.length, codeA = bitCode(points[0], bbox2), part = [], i, codeB, lastCode;
|
|
4945
|
-
let a;
|
|
4946
|
-
let b;
|
|
4947
|
-
if (!result) result = [];
|
|
4948
|
-
for (i = 1; i < len; i++) {
|
|
4949
|
-
a = points[i - 1];
|
|
4950
|
-
b = points[i];
|
|
4951
|
-
codeB = lastCode = bitCode(b, bbox2);
|
|
4952
|
-
while (true) {
|
|
4953
|
-
if (!(codeA | codeB)) {
|
|
4954
|
-
part.push(a);
|
|
4955
|
-
if (codeB !== lastCode) {
|
|
4956
|
-
part.push(b);
|
|
4957
|
-
if (i < len - 1) {
|
|
4958
|
-
result.push(part);
|
|
4959
|
-
part = [];
|
|
4960
|
-
}
|
|
4961
|
-
} else if (i === len - 1) {
|
|
4962
|
-
part.push(b);
|
|
4963
|
-
}
|
|
4964
|
-
break;
|
|
4965
|
-
} else if (codeA & codeB) {
|
|
4966
|
-
break;
|
|
4967
|
-
} else if (codeA) {
|
|
4968
|
-
a = intersect2(a, b, codeA, bbox2);
|
|
4969
|
-
codeA = bitCode(a, bbox2);
|
|
4970
|
-
} else {
|
|
4971
|
-
b = intersect2(a, b, codeB, bbox2);
|
|
4972
|
-
codeB = bitCode(b, bbox2);
|
|
4973
|
-
}
|
|
4974
|
-
}
|
|
4975
|
-
codeA = lastCode;
|
|
4976
|
-
}
|
|
4977
|
-
if (part.length) result.push(part);
|
|
4978
|
-
return result;
|
|
4979
|
-
}
|
|
4980
|
-
function polygonclip(points, bbox2) {
|
|
4981
|
-
var result, edge, prev, prevInside, i, p, inside;
|
|
4982
|
-
for (edge = 1; edge <= 8; edge *= 2) {
|
|
4983
|
-
result = [];
|
|
4984
|
-
prev = points[points.length - 1];
|
|
4985
|
-
prevInside = !(bitCode(prev, bbox2) & edge);
|
|
4986
|
-
for (i = 0; i < points.length; i++) {
|
|
4987
|
-
p = points[i];
|
|
4988
|
-
inside = !(bitCode(p, bbox2) & edge);
|
|
4989
|
-
if (inside !== prevInside) result.push(intersect2(prev, p, edge, bbox2));
|
|
4990
|
-
if (inside) result.push(p);
|
|
4991
|
-
prev = p;
|
|
4992
|
-
prevInside = inside;
|
|
4993
|
-
}
|
|
4994
|
-
points = result;
|
|
4995
|
-
if (!points.length) break;
|
|
4996
|
-
}
|
|
4997
|
-
return result;
|
|
4998
|
-
}
|
|
4999
|
-
function intersect2(a, b, edge, bbox2) {
|
|
5000
|
-
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;
|
|
5001
|
-
}
|
|
5002
|
-
function bitCode(p, bbox2) {
|
|
5003
|
-
var code = 0;
|
|
5004
|
-
if (p[0] < bbox2[0]) code |= 1;
|
|
5005
|
-
else if (p[0] > bbox2[2]) code |= 2;
|
|
5006
|
-
if (p[1] < bbox2[1]) code |= 4;
|
|
5007
|
-
else if (p[1] > bbox2[3]) code |= 8;
|
|
5008
|
-
return code;
|
|
5009
|
-
}
|
|
5010
|
-
function bboxClip(feature2, bbox2) {
|
|
5011
|
-
const geom = getGeom(feature2);
|
|
5012
|
-
const type = geom.type;
|
|
5013
|
-
const properties = feature2.type === "Feature" ? feature2.properties : {};
|
|
5014
|
-
let coords = geom.coordinates;
|
|
5015
|
-
switch (type) {
|
|
5016
|
-
case "LineString":
|
|
5017
|
-
case "MultiLineString": {
|
|
5018
|
-
const lines = [];
|
|
5019
|
-
if (type === "LineString") {
|
|
5020
|
-
coords = [coords];
|
|
5021
|
-
}
|
|
5022
|
-
coords.forEach((line) => {
|
|
5023
|
-
lineclip(line, bbox2, lines);
|
|
5024
|
-
});
|
|
5025
|
-
if (lines.length === 1) {
|
|
5026
|
-
return lineString(lines[0], properties);
|
|
5027
|
-
}
|
|
5028
|
-
return multiLineString(lines, properties);
|
|
5029
|
-
}
|
|
5030
|
-
case "Polygon":
|
|
5031
|
-
return polygon(clipPolygon(coords, bbox2), properties);
|
|
5032
|
-
case "MultiPolygon":
|
|
5033
|
-
return multiPolygon(
|
|
5034
|
-
coords.map((poly) => {
|
|
5035
|
-
return clipPolygon(poly, bbox2);
|
|
5036
|
-
}),
|
|
5037
|
-
properties
|
|
5038
|
-
);
|
|
5039
|
-
default:
|
|
5040
|
-
throw new Error("geometry " + type + " not supported");
|
|
5041
|
-
}
|
|
5042
|
-
}
|
|
5043
|
-
function clipPolygon(rings, bbox2) {
|
|
5044
|
-
const outRings = [];
|
|
5045
|
-
for (const ring of rings) {
|
|
5046
|
-
const clipped = polygonclip(ring, bbox2);
|
|
5047
|
-
if (clipped.length > 0) {
|
|
5048
|
-
if (clipped[0][0] !== clipped[clipped.length - 1][0] || clipped[0][1] !== clipped[clipped.length - 1][1]) {
|
|
5049
|
-
clipped.push(clipped[0]);
|
|
5050
|
-
}
|
|
5051
|
-
if (clipped.length >= 4) {
|
|
5052
|
-
outRings.push(clipped);
|
|
5053
|
-
}
|
|
5054
|
-
}
|
|
5055
|
-
}
|
|
5056
|
-
return outRings;
|
|
5057
|
-
}
|
|
5058
|
-
var turf_bbox_clip_default = bboxClip;
|
|
5059
|
-
|
|
5060
|
-
// src/filters/tileIntersection.ts
|
|
5061
|
-
function intersectTileGeometry(tileBbox, tileFormat, spatialFilter) {
|
|
5062
|
-
const tilePolygon = turf_bbox_polygon_default(tileBbox);
|
|
5063
|
-
if (!spatialFilter || turf_boolean_within_default(tilePolygon, spatialFilter)) {
|
|
5064
|
-
return true;
|
|
5065
|
-
}
|
|
5066
|
-
const clippedSpatialFilter = turf_intersect_default(
|
|
5067
|
-
featureCollection([tilePolygon, feature(spatialFilter)])
|
|
5068
|
-
);
|
|
5069
|
-
if (!clippedSpatialFilter) {
|
|
5070
|
-
return false;
|
|
5071
|
-
}
|
|
5072
|
-
return tileFormat === "mvt" /* MVT */ ? transformToTileCoords(clippedSpatialFilter.geometry, tileBbox) : clippedSpatialFilter.geometry;
|
|
5073
|
-
}
|
|
5074
|
-
function intersectTileRaster(parent, cellResolution, spatialFilter) {
|
|
5075
|
-
return intersectTileQuadbin(parent, cellResolution, spatialFilter);
|
|
5076
|
-
}
|
|
5077
|
-
function intersectTileQuadbin(parent, cellResolution, spatialFilter) {
|
|
5078
|
-
const tilePolygon = quadbinCellToBoundary(parent);
|
|
5079
|
-
if (!spatialFilter || turf_boolean_within_default(tilePolygon, spatialFilter)) {
|
|
5080
|
-
return true;
|
|
5081
|
-
}
|
|
5082
|
-
const clippedSpatialFilter = turf_intersect_default(
|
|
5083
|
-
featureCollection([feature(tilePolygon), feature(spatialFilter)])
|
|
5084
|
-
);
|
|
5085
|
-
if (!clippedSpatialFilter) {
|
|
5086
|
-
return false;
|
|
5087
|
-
}
|
|
5088
|
-
const cells = quadbinGeometryToCells(
|
|
5089
|
-
clippedSpatialFilter.geometry,
|
|
5090
|
-
cellResolution
|
|
5091
|
-
);
|
|
5092
|
-
return new Set(cells);
|
|
5093
|
-
}
|
|
5094
|
-
var BBOX_WEST = [-180, -90, 0, 90];
|
|
5095
|
-
var BBOX_EAST = [0, -90, 180, 90];
|
|
5096
|
-
function intersectTileH3(cellResolution, spatialFilter) {
|
|
5097
|
-
if (!spatialFilter) {
|
|
5098
|
-
return true;
|
|
5099
|
-
}
|
|
5100
|
-
const spatialFilterFeature = feature(spatialFilter);
|
|
5101
|
-
const cellsWest = h3PolygonToCells(
|
|
5102
|
-
turf_bbox_clip_default(spatialFilterFeature, BBOX_WEST).geometry.coordinates,
|
|
5103
|
-
cellResolution,
|
|
5104
|
-
true
|
|
5105
|
-
);
|
|
5106
|
-
const cellsEast = h3PolygonToCells(
|
|
5107
|
-
turf_bbox_clip_default(spatialFilterFeature, BBOX_EAST).geometry.coordinates,
|
|
5108
|
-
cellResolution,
|
|
5109
|
-
true
|
|
5110
|
-
);
|
|
5111
|
-
return new Set(cellsWest.concat(cellsEast));
|
|
5112
|
-
}
|
|
5113
4934
|
|
|
5114
4935
|
// src/filters/tileFeaturesGeometries.ts
|
|
5115
4936
|
var FEATURE_GEOM_PROPERTY = "__geomValue";
|
|
@@ -5125,45 +4946,55 @@ function tileFeaturesGeometries({
|
|
|
5125
4946
|
if (tile.isVisible === false || !tile.data) {
|
|
5126
4947
|
continue;
|
|
5127
4948
|
}
|
|
5128
|
-
const
|
|
4949
|
+
const bbox2 = [
|
|
5129
4950
|
tile.bbox.west,
|
|
5130
4951
|
tile.bbox.south,
|
|
5131
4952
|
tile.bbox.east,
|
|
5132
4953
|
tile.bbox.north
|
|
5133
4954
|
];
|
|
5134
|
-
const
|
|
5135
|
-
|
|
5136
|
-
|
|
5137
|
-
|
|
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])
|
|
5138
4964
|
);
|
|
5139
|
-
if (
|
|
5140
|
-
|
|
4965
|
+
if (!clippedGeometryToIntersect) {
|
|
4966
|
+
continue;
|
|
4967
|
+
}
|
|
4968
|
+
const transformedGeometryToIntersect = tileFormat === "mvt" /* MVT */ ? transformToTileCoords(clippedGeometryToIntersect.geometry, bbox2) : clippedGeometryToIntersect.geometry;
|
|
5141
4969
|
calculateFeatures({
|
|
5142
4970
|
map,
|
|
5143
|
-
|
|
4971
|
+
tileIsFullyVisible,
|
|
4972
|
+
geometryIntersection: transformedGeometryToIntersect,
|
|
5144
4973
|
data: tile.data.points,
|
|
5145
4974
|
type: "Point",
|
|
5146
|
-
bbox:
|
|
4975
|
+
bbox: bbox2,
|
|
5147
4976
|
tileFormat,
|
|
5148
4977
|
uniqueIdProperty,
|
|
5149
4978
|
options
|
|
5150
4979
|
});
|
|
5151
4980
|
calculateFeatures({
|
|
5152
4981
|
map,
|
|
5153
|
-
|
|
4982
|
+
tileIsFullyVisible,
|
|
4983
|
+
geometryIntersection: transformedGeometryToIntersect,
|
|
5154
4984
|
data: tile.data.lines,
|
|
5155
4985
|
type: "LineString",
|
|
5156
|
-
bbox:
|
|
4986
|
+
bbox: bbox2,
|
|
5157
4987
|
tileFormat,
|
|
5158
4988
|
uniqueIdProperty,
|
|
5159
4989
|
options
|
|
5160
4990
|
});
|
|
5161
4991
|
calculateFeatures({
|
|
5162
4992
|
map,
|
|
5163
|
-
|
|
4993
|
+
tileIsFullyVisible,
|
|
4994
|
+
geometryIntersection: transformedGeometryToIntersect,
|
|
5164
4995
|
data: tile.data.polygons,
|
|
5165
4996
|
type: "Polygon",
|
|
5166
|
-
bbox:
|
|
4997
|
+
bbox: bbox2,
|
|
5167
4998
|
tileFormat,
|
|
5168
4999
|
uniqueIdProperty,
|
|
5169
5000
|
options
|
|
@@ -5181,7 +5012,7 @@ function processTileFeatureProperties({
|
|
|
5181
5012
|
tileFormat,
|
|
5182
5013
|
uniqueIdProperty,
|
|
5183
5014
|
storeGeometry,
|
|
5184
|
-
|
|
5015
|
+
geometryIntersection
|
|
5185
5016
|
}) {
|
|
5186
5017
|
const tileProps = getPropertiesFromTile(data, startIndex);
|
|
5187
5018
|
const uniquePropertyValue = getUniquePropertyValue(
|
|
@@ -5193,7 +5024,7 @@ function processTileFeatureProperties({
|
|
|
5193
5024
|
return;
|
|
5194
5025
|
}
|
|
5195
5026
|
let geometry = null;
|
|
5196
|
-
if (storeGeometry ||
|
|
5027
|
+
if (storeGeometry || geometryIntersection) {
|
|
5197
5028
|
const { positions } = data;
|
|
5198
5029
|
const ringCoordinates = getRingCoordinatesFor(
|
|
5199
5030
|
startIndex,
|
|
@@ -5202,7 +5033,7 @@ function processTileFeatureProperties({
|
|
|
5202
5033
|
);
|
|
5203
5034
|
geometry = getFeatureByType(ringCoordinates, type);
|
|
5204
5035
|
}
|
|
5205
|
-
if (geometry &&
|
|
5036
|
+
if (geometry && geometryIntersection && !turf_boolean_intersects_default(geometry, geometryIntersection)) {
|
|
5206
5037
|
return;
|
|
5207
5038
|
}
|
|
5208
5039
|
const properties = parseProperties(tileProps);
|
|
@@ -5214,7 +5045,7 @@ function processTileFeatureProperties({
|
|
|
5214
5045
|
function addIntersectedFeaturesInTile({
|
|
5215
5046
|
map,
|
|
5216
5047
|
data,
|
|
5217
|
-
|
|
5048
|
+
geometryIntersection,
|
|
5218
5049
|
type,
|
|
5219
5050
|
bbox: bbox2,
|
|
5220
5051
|
tileFormat,
|
|
@@ -5236,7 +5067,7 @@ function addIntersectedFeaturesInTile({
|
|
|
5236
5067
|
tileFormat,
|
|
5237
5068
|
uniqueIdProperty,
|
|
5238
5069
|
storeGeometry,
|
|
5239
|
-
|
|
5070
|
+
geometryIntersection
|
|
5240
5071
|
});
|
|
5241
5072
|
}
|
|
5242
5073
|
}
|
|
@@ -5318,7 +5149,8 @@ function getRingCoordinatesFor(startIndex, endIndex, positions) {
|
|
|
5318
5149
|
}
|
|
5319
5150
|
function calculateFeatures({
|
|
5320
5151
|
map,
|
|
5321
|
-
|
|
5152
|
+
tileIsFullyVisible,
|
|
5153
|
+
geometryIntersection,
|
|
5322
5154
|
data,
|
|
5323
5155
|
type,
|
|
5324
5156
|
bbox: bbox2,
|
|
@@ -5329,7 +5161,7 @@ function calculateFeatures({
|
|
|
5329
5161
|
if (!data?.properties.length) {
|
|
5330
5162
|
return;
|
|
5331
5163
|
}
|
|
5332
|
-
if (
|
|
5164
|
+
if (tileIsFullyVisible) {
|
|
5333
5165
|
addAllFeaturesInTile({
|
|
5334
5166
|
map,
|
|
5335
5167
|
data,
|
|
@@ -5343,7 +5175,7 @@ function calculateFeatures({
|
|
|
5343
5175
|
addIntersectedFeaturesInTile({
|
|
5344
5176
|
map,
|
|
5345
5177
|
data,
|
|
5346
|
-
|
|
5178
|
+
geometryIntersection,
|
|
5347
5179
|
type,
|
|
5348
5180
|
bbox: bbox2,
|
|
5349
5181
|
tileFormat,
|
|
@@ -5393,8 +5225,128 @@ function createIndicesForPoints(data) {
|
|
|
5393
5225
|
}
|
|
5394
5226
|
|
|
5395
5227
|
// src/filters/tileFeaturesSpatialIndex.ts
|
|
5396
|
-
import { getResolution as quadbinGetResolution } from "quadbin";
|
|
5397
|
-
|
|
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";
|
|
5398
5350
|
function tileFeaturesSpatialIndex({
|
|
5399
5351
|
tiles,
|
|
5400
5352
|
spatialFilter,
|
|
@@ -5403,42 +5355,28 @@ function tileFeaturesSpatialIndex({
|
|
|
5403
5355
|
}) {
|
|
5404
5356
|
const map = /* @__PURE__ */ new Map();
|
|
5405
5357
|
const spatialIndex = getSpatialIndex(spatialDataType);
|
|
5406
|
-
const
|
|
5358
|
+
const resolution = getResolution(tiles, spatialIndex);
|
|
5407
5359
|
const spatialIndexIDName = spatialDataColumn ? spatialDataColumn : spatialIndex;
|
|
5408
|
-
if (!
|
|
5360
|
+
if (!resolution) {
|
|
5409
5361
|
return [];
|
|
5410
5362
|
}
|
|
5411
|
-
|
|
5412
|
-
if (
|
|
5413
|
-
|
|
5363
|
+
const cells = getCellsCoverGeometry(spatialFilter, spatialIndex, resolution);
|
|
5364
|
+
if (!cells?.length) {
|
|
5365
|
+
return [];
|
|
5414
5366
|
}
|
|
5367
|
+
const cellsSet = new Set(cells);
|
|
5415
5368
|
for (const tile of tiles) {
|
|
5416
5369
|
if (tile.isVisible === false || !tile.data) {
|
|
5417
5370
|
continue;
|
|
5418
5371
|
}
|
|
5419
|
-
if (spatialIndex === "quadbin" /* QUADBIN */) {
|
|
5420
|
-
const parent = getTileIndex(tile, spatialIndex);
|
|
5421
|
-
intersection3 = intersectTileQuadbin(
|
|
5422
|
-
parent,
|
|
5423
|
-
cellResolution,
|
|
5424
|
-
spatialFilter
|
|
5425
|
-
);
|
|
5426
|
-
}
|
|
5427
|
-
if (!intersection3) continue;
|
|
5428
5372
|
tile.data.forEach((d) => {
|
|
5429
|
-
if (
|
|
5373
|
+
if (cellsSet.has(d.id)) {
|
|
5430
5374
|
map.set(d.id, { ...d.properties, [spatialIndexIDName]: d.id });
|
|
5431
5375
|
}
|
|
5432
5376
|
});
|
|
5433
5377
|
}
|
|
5434
5378
|
return Array.from(map.values());
|
|
5435
5379
|
}
|
|
5436
|
-
function getTileIndex(tile, spatialIndex) {
|
|
5437
|
-
if (spatialIndex === "quadbin" /* QUADBIN */) {
|
|
5438
|
-
return tile.index.q;
|
|
5439
|
-
}
|
|
5440
|
-
return tile.id;
|
|
5441
|
-
}
|
|
5442
5380
|
function getResolution(tiles, spatialIndex) {
|
|
5443
5381
|
const data = tiles.find((tile) => tile.data?.length)?.data;
|
|
5444
5382
|
if (!data) {
|
|
@@ -5451,6 +5389,26 @@ function getResolution(tiles, spatialIndex) {
|
|
|
5451
5389
|
return h3GetResolution(data[0].id);
|
|
5452
5390
|
}
|
|
5453
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
|
+
}
|
|
5454
5412
|
function getSpatialIndex(spatialDataType) {
|
|
5455
5413
|
switch (spatialDataType) {
|
|
5456
5414
|
case "h3":
|
|
@@ -5476,7 +5434,9 @@ var DEFAULT_AGGREGATION_EXP = `1 AS ${DEFAULT_AGGREGATION_EXP_ALIAS}`;
|
|
|
5476
5434
|
// src/filters/tileFeaturesRaster.ts
|
|
5477
5435
|
import {
|
|
5478
5436
|
cellToChildren as _cellToChildren,
|
|
5437
|
+
cellToBoundary,
|
|
5479
5438
|
cellToTile,
|
|
5439
|
+
geometryToCells as geometryToCells2,
|
|
5480
5440
|
getResolution as getResolution2
|
|
5481
5441
|
} from "quadbin";
|
|
5482
5442
|
function tileFeaturesRaster({
|
|
@@ -5495,15 +5455,15 @@ function tileFeaturesRaster({
|
|
|
5495
5455
|
const data = /* @__PURE__ */ new Map();
|
|
5496
5456
|
for (const tile of tiles) {
|
|
5497
5457
|
const parent = tile.index.q;
|
|
5498
|
-
const
|
|
5499
|
-
|
|
5500
|
-
|
|
5501
|
-
options.spatialFilter
|
|
5458
|
+
const tilePolygon = cellToBoundary(parent);
|
|
5459
|
+
const tileFilter = turf_intersect_default(
|
|
5460
|
+
featureCollection([feature(tilePolygon), feature(options.spatialFilter)])
|
|
5502
5461
|
);
|
|
5503
|
-
|
|
5462
|
+
const needsFilter = tileFilter ? !turf_boolean_within_default(tilePolygon, options.spatialFilter) : false;
|
|
5463
|
+
const tileFilterCells = needsFilter ? new Set(geometryToCells2(tileFilter.geometry, cellResolution)) : null;
|
|
5504
5464
|
const tileSortedCells = cellToChildrenSorted(parent, cellResolution);
|
|
5505
5465
|
for (let i = 0; i < tileSortedCells.length; i++) {
|
|
5506
|
-
if (
|
|
5466
|
+
if (needsFilter && !tileFilterCells.has(tileSortedCells[i])) {
|
|
5507
5467
|
continue;
|
|
5508
5468
|
}
|
|
5509
5469
|
const cellData = {};
|
|
@@ -6292,6 +6252,9 @@ function getApplicableFilters(owner, filters) {
|
|
|
6292
6252
|
return applicableFilters;
|
|
6293
6253
|
}
|
|
6294
6254
|
|
|
6255
|
+
// src/widget-sources/constants.ts
|
|
6256
|
+
var OTHERS_CATEGORY_NAME = "_carto_others";
|
|
6257
|
+
|
|
6295
6258
|
// src/widget-sources/widget-remote-source.ts
|
|
6296
6259
|
var WidgetRemoteSource = class extends WidgetSource {
|
|
6297
6260
|
_getModelSource(filters, filterOwner) {
|
|
@@ -6315,13 +6278,21 @@ var WidgetRemoteSource = class extends WidgetSource {
|
|
|
6315
6278
|
filterOwner,
|
|
6316
6279
|
spatialFilter,
|
|
6317
6280
|
spatialFiltersMode,
|
|
6281
|
+
rawResult,
|
|
6318
6282
|
...params
|
|
6319
6283
|
} = options;
|
|
6320
|
-
const {
|
|
6284
|
+
const {
|
|
6285
|
+
column,
|
|
6286
|
+
operation: operation2,
|
|
6287
|
+
operationColumn,
|
|
6288
|
+
operationExp,
|
|
6289
|
+
othersThreshold,
|
|
6290
|
+
orderBy
|
|
6291
|
+
} = params;
|
|
6321
6292
|
if (operation2 === AggregationTypes.Custom) {
|
|
6322
6293
|
assert2(operationExp, "operationExp is required for custom operation");
|
|
6323
6294
|
}
|
|
6324
|
-
|
|
6295
|
+
const result = await executeModel({
|
|
6325
6296
|
model: "category",
|
|
6326
6297
|
source: {
|
|
6327
6298
|
...this.getModelSource(filters, filterOwner),
|
|
@@ -6332,10 +6303,23 @@ var WidgetRemoteSource = class extends WidgetSource {
|
|
|
6332
6303
|
column,
|
|
6333
6304
|
operation: operation2,
|
|
6334
6305
|
operationExp,
|
|
6335
|
-
operationColumn: operationColumn || column
|
|
6306
|
+
operationColumn: operationColumn || column,
|
|
6307
|
+
othersThreshold,
|
|
6308
|
+
orderBy
|
|
6336
6309
|
},
|
|
6337
6310
|
opts: { signal, headers: this.props.headers }
|
|
6338
|
-
})
|
|
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
|
+
];
|
|
6339
6323
|
}
|
|
6340
6324
|
async getFeatures(options) {
|
|
6341
6325
|
const {
|
|
@@ -6728,10 +6712,12 @@ function groupValuesByColumn({
|
|
|
6728
6712
|
valuesColumns,
|
|
6729
6713
|
joinOperation,
|
|
6730
6714
|
keysColumn,
|
|
6731
|
-
operation: operation2
|
|
6715
|
+
operation: operation2,
|
|
6716
|
+
othersThreshold,
|
|
6717
|
+
orderBy = "frequency_desc"
|
|
6732
6718
|
}) {
|
|
6733
6719
|
if (Array.isArray(data) && data.length === 0) {
|
|
6734
|
-
return null;
|
|
6720
|
+
return { rows: null };
|
|
6735
6721
|
}
|
|
6736
6722
|
const groups = data.reduce((accumulator, item) => {
|
|
6737
6723
|
const group2 = item[keysColumn];
|
|
@@ -6746,13 +6732,44 @@ function groupValuesByColumn({
|
|
|
6746
6732
|
return accumulator;
|
|
6747
6733
|
}, /* @__PURE__ */ new Map());
|
|
6748
6734
|
const targetOperation = aggregationFunctions[operation2];
|
|
6749
|
-
if (targetOperation) {
|
|
6750
|
-
return
|
|
6751
|
-
name,
|
|
6752
|
-
value: targetOperation(value)
|
|
6753
|
-
}));
|
|
6735
|
+
if (!targetOperation) {
|
|
6736
|
+
return { rows: [] };
|
|
6754
6737
|
}
|
|
6755
|
-
|
|
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
|
+
};
|
|
6754
|
+
}
|
|
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");
|
|
6756
6773
|
}
|
|
6757
6774
|
|
|
6758
6775
|
// src/utils/dateUtils.ts
|
|
@@ -7226,7 +7243,7 @@ var WidgetTilesetSourceImpl = class extends WidgetSource {
|
|
|
7226
7243
|
}
|
|
7227
7244
|
_extractTileFeatures(spatialFilter) {
|
|
7228
7245
|
const prevInputs = this._tileFeatureExtractPreviousInputs;
|
|
7229
|
-
if (this._features.length &&
|
|
7246
|
+
if (this._features.length && prevInputs.spatialFilter && booleanEqual(prevInputs.spatialFilter, spatialFilter)) {
|
|
7230
7247
|
return;
|
|
7231
7248
|
}
|
|
7232
7249
|
this._features = tileFeatures({
|
|
@@ -7315,7 +7332,10 @@ var WidgetTilesetSourceImpl = class extends WidgetSource {
|
|
|
7315
7332
|
joinOperation,
|
|
7316
7333
|
filters,
|
|
7317
7334
|
filterOwner,
|
|
7318
|
-
spatialFilter
|
|
7335
|
+
spatialFilter,
|
|
7336
|
+
othersThreshold,
|
|
7337
|
+
orderBy = "frequency_desc",
|
|
7338
|
+
rawResult
|
|
7319
7339
|
}) {
|
|
7320
7340
|
const filteredFeatures = this._getFilteredFeatures(
|
|
7321
7341
|
spatialFilter,
|
|
@@ -7326,14 +7346,25 @@ var WidgetTilesetSourceImpl = class extends WidgetSource {
|
|
|
7326
7346
|
return [];
|
|
7327
7347
|
}
|
|
7328
7348
|
assertColumn(this._features, column, operationColumn);
|
|
7329
|
-
const
|
|
7349
|
+
const result = groupValuesByColumn({
|
|
7330
7350
|
data: filteredFeatures,
|
|
7331
7351
|
valuesColumns: normalizeColumns(operationColumn || column),
|
|
7332
7352
|
joinOperation,
|
|
7333
7353
|
keysColumn: column,
|
|
7334
|
-
operation: operation2
|
|
7354
|
+
operation: operation2,
|
|
7355
|
+
othersThreshold,
|
|
7356
|
+
orderBy
|
|
7335
7357
|
});
|
|
7336
|
-
|
|
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
|
+
];
|
|
7337
7368
|
}
|
|
7338
7369
|
async getScatter({
|
|
7339
7370
|
xAxisColumn,
|
|
@@ -7466,6 +7497,7 @@ var WidgetTilesetSourceImpl = class extends WidgetSource {
|
|
|
7466
7497
|
* INTERNAL
|
|
7467
7498
|
*/
|
|
7468
7499
|
_getFilteredFeatures(spatialFilter, filters, filterOwner) {
|
|
7500
|
+
assert2(spatialFilter, "spatialFilter required for tilesets");
|
|
7469
7501
|
this._extractTileFeatures(spatialFilter);
|
|
7470
7502
|
return applyFilters(
|
|
7471
7503
|
this._features,
|
|
@@ -7489,11 +7521,6 @@ function assertColumn(features, ...columnArgs) {
|
|
|
7489
7521
|
function normalizeColumns(columns) {
|
|
7490
7522
|
return Array.isArray(columns) ? columns : typeof columns === "string" ? [columns] : [];
|
|
7491
7523
|
}
|
|
7492
|
-
function spatialFilterEquals(a, b) {
|
|
7493
|
-
if (a === b) return true;
|
|
7494
|
-
if (!a || !b) return false;
|
|
7495
|
-
return booleanEqual(a, b);
|
|
7496
|
-
}
|
|
7497
7524
|
|
|
7498
7525
|
// src/widget-sources/widget-tileset-source.ts
|
|
7499
7526
|
var WidgetTilesetSource = class extends WidgetSource {
|
|
@@ -10079,6 +10106,7 @@ export {
|
|
|
10079
10106
|
FEATURE_GEOM_PROPERTY,
|
|
10080
10107
|
FilterType,
|
|
10081
10108
|
OPACITY_MAP,
|
|
10109
|
+
OTHERS_CATEGORY_NAME,
|
|
10082
10110
|
Provider,
|
|
10083
10111
|
SOURCE_DEFAULTS,
|
|
10084
10112
|
SchemaFieldType,
|
|
@@ -10129,6 +10157,7 @@ export {
|
|
|
10129
10157
|
getLayerProps,
|
|
10130
10158
|
getMaxMarkerSize,
|
|
10131
10159
|
getSizeAccessor,
|
|
10160
|
+
getSorter,
|
|
10132
10161
|
getSpatialIndexFromGeoColumn,
|
|
10133
10162
|
getTextAccessor,
|
|
10134
10163
|
groupValuesByColumn,
|