@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/worker.js
CHANGED
|
@@ -1505,110 +1505,6 @@ 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
|
-
|
|
1612
1508
|
// node_modules/@turf/bbox-polygon/dist/esm/index.js
|
|
1613
1509
|
function bboxPolygon(bbox2, options = {}) {
|
|
1614
1510
|
const west = Number(bbox2[0]);
|
|
@@ -1927,7 +1823,7 @@ var MAX_SAFE_INTEGER = 9007199254740991;
|
|
|
1927
1823
|
var POWS_TEN = [1, 10, 100, 1e3, 1e4, 1e5, 1e6, 1e7, 1e8, 1e9, 1e10, 1e11, 1e12, 1e13];
|
|
1928
1824
|
var SQRT_BASE = 1e7;
|
|
1929
1825
|
var MAX = 1e9;
|
|
1930
|
-
function
|
|
1826
|
+
function clone(configObject) {
|
|
1931
1827
|
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 = {
|
|
1932
1828
|
prefix: "",
|
|
1933
1829
|
groupSize: 3,
|
|
@@ -2053,7 +1949,7 @@ function clone2(configObject) {
|
|
|
2053
1949
|
x.c = [x.e = 0];
|
|
2054
1950
|
}
|
|
2055
1951
|
}
|
|
2056
|
-
BigNumber2.clone =
|
|
1952
|
+
BigNumber2.clone = clone;
|
|
2057
1953
|
BigNumber2.ROUND_UP = 0;
|
|
2058
1954
|
BigNumber2.ROUND_DOWN = 1;
|
|
2059
1955
|
BigNumber2.ROUND_CEIL = 2;
|
|
@@ -3256,7 +3152,7 @@ function toFixedPoint(str, e, z) {
|
|
|
3256
3152
|
}
|
|
3257
3153
|
return str;
|
|
3258
3154
|
}
|
|
3259
|
-
var BigNumber =
|
|
3155
|
+
var BigNumber = clone();
|
|
3260
3156
|
var bignumber_default = BigNumber;
|
|
3261
3157
|
|
|
3262
3158
|
// node_modules/splaytree-ts/dist/esm/index.js
|
|
@@ -4825,7 +4721,117 @@ function intersect(features, options = {}) {
|
|
|
4825
4721
|
}
|
|
4826
4722
|
var turf_intersect_default = intersect;
|
|
4827
4723
|
|
|
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
|
+
|
|
4828
4781
|
// 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
|
|
4829
4835
|
var TRANSFORM_FN2 = {
|
|
4830
4836
|
Point: transformPoint2,
|
|
4831
4837
|
MultiPoint: transformMultiPoint2,
|
|
@@ -4834,10 +4840,10 @@ var TRANSFORM_FN2 = {
|
|
|
4834
4840
|
Polygon: transformPolygon2,
|
|
4835
4841
|
MultiPolygon: transformMultiPolygon2
|
|
4836
4842
|
};
|
|
4837
|
-
function
|
|
4843
|
+
function transformTileCoordsToWGS84(geometry, bbox2) {
|
|
4838
4844
|
const [west, south, east, north] = bbox2;
|
|
4839
|
-
const nw =
|
|
4840
|
-
const se =
|
|
4845
|
+
const nw = lngLatToWorld([west, north]);
|
|
4846
|
+
const se = lngLatToWorld([east, south]);
|
|
4841
4847
|
const projectedBbox = [nw, se];
|
|
4842
4848
|
if (geometry.type === "GeometryCollection") {
|
|
4843
4849
|
throw new Error("Unsupported geometry type GeometryCollection");
|
|
@@ -4847,12 +4853,12 @@ function transformToTileCoords(geometry, bbox2) {
|
|
|
4847
4853
|
return { ...geometry, coordinates };
|
|
4848
4854
|
}
|
|
4849
4855
|
function transformPoint2([pointX, pointY], [nw, se]) {
|
|
4850
|
-
const x =
|
|
4851
|
-
const y =
|
|
4852
|
-
return [x, y];
|
|
4856
|
+
const x = lerp(nw[0], se[0], pointX);
|
|
4857
|
+
const y = lerp(nw[1], se[1], pointY);
|
|
4858
|
+
return worldToLngLat([x, y]);
|
|
4853
4859
|
}
|
|
4854
4860
|
function getPoints2(geometry, bbox2) {
|
|
4855
|
-
return geometry.map((g) => transformPoint2(
|
|
4861
|
+
return geometry.map((g) => transformPoint2(g, bbox2));
|
|
4856
4862
|
}
|
|
4857
4863
|
function transformMultiPoint2(multiPoint, bbox2) {
|
|
4858
4864
|
return getPoints2(multiPoint, bbox2);
|
|
@@ -4871,191 +4877,6 @@ function transformPolygon2(polygon2, bbox2) {
|
|
|
4871
4877
|
function transformMultiPolygon2(multiPolygon2, bbox2) {
|
|
4872
4878
|
return multiPolygon2.map((polygon2) => transformPolygon2(polygon2, bbox2));
|
|
4873
4879
|
}
|
|
4874
|
-
function projectFlat(xyz) {
|
|
4875
|
-
return lngLatToWorld(xyz);
|
|
4876
|
-
}
|
|
4877
|
-
function inverseLerp(a, b, x) {
|
|
4878
|
-
return (x - a) / (b - a);
|
|
4879
|
-
}
|
|
4880
|
-
|
|
4881
|
-
// src/filters/tileIntersection.ts
|
|
4882
|
-
import {
|
|
4883
|
-
cellToBoundary as quadbinCellToBoundary,
|
|
4884
|
-
geometryToCells as quadbinGeometryToCells
|
|
4885
|
-
} from "quadbin";
|
|
4886
|
-
import { polygonToCells as h3PolygonToCells } from "h3-js";
|
|
4887
|
-
|
|
4888
|
-
// node_modules/@turf/bbox-clip/dist/esm/index.js
|
|
4889
|
-
function lineclip(points, bbox2, result) {
|
|
4890
|
-
var len = points.length, codeA = bitCode(points[0], bbox2), part = [], i, codeB, lastCode;
|
|
4891
|
-
let a;
|
|
4892
|
-
let b;
|
|
4893
|
-
if (!result) result = [];
|
|
4894
|
-
for (i = 1; i < len; i++) {
|
|
4895
|
-
a = points[i - 1];
|
|
4896
|
-
b = points[i];
|
|
4897
|
-
codeB = lastCode = bitCode(b, bbox2);
|
|
4898
|
-
while (true) {
|
|
4899
|
-
if (!(codeA | codeB)) {
|
|
4900
|
-
part.push(a);
|
|
4901
|
-
if (codeB !== lastCode) {
|
|
4902
|
-
part.push(b);
|
|
4903
|
-
if (i < len - 1) {
|
|
4904
|
-
result.push(part);
|
|
4905
|
-
part = [];
|
|
4906
|
-
}
|
|
4907
|
-
} else if (i === len - 1) {
|
|
4908
|
-
part.push(b);
|
|
4909
|
-
}
|
|
4910
|
-
break;
|
|
4911
|
-
} else if (codeA & codeB) {
|
|
4912
|
-
break;
|
|
4913
|
-
} else if (codeA) {
|
|
4914
|
-
a = intersect2(a, b, codeA, bbox2);
|
|
4915
|
-
codeA = bitCode(a, bbox2);
|
|
4916
|
-
} else {
|
|
4917
|
-
b = intersect2(a, b, codeB, bbox2);
|
|
4918
|
-
codeB = bitCode(b, bbox2);
|
|
4919
|
-
}
|
|
4920
|
-
}
|
|
4921
|
-
codeA = lastCode;
|
|
4922
|
-
}
|
|
4923
|
-
if (part.length) result.push(part);
|
|
4924
|
-
return result;
|
|
4925
|
-
}
|
|
4926
|
-
function polygonclip(points, bbox2) {
|
|
4927
|
-
var result, edge, prev, prevInside, i, p, inside;
|
|
4928
|
-
for (edge = 1; edge <= 8; edge *= 2) {
|
|
4929
|
-
result = [];
|
|
4930
|
-
prev = points[points.length - 1];
|
|
4931
|
-
prevInside = !(bitCode(prev, bbox2) & edge);
|
|
4932
|
-
for (i = 0; i < points.length; i++) {
|
|
4933
|
-
p = points[i];
|
|
4934
|
-
inside = !(bitCode(p, bbox2) & edge);
|
|
4935
|
-
if (inside !== prevInside) result.push(intersect2(prev, p, edge, bbox2));
|
|
4936
|
-
if (inside) result.push(p);
|
|
4937
|
-
prev = p;
|
|
4938
|
-
prevInside = inside;
|
|
4939
|
-
}
|
|
4940
|
-
points = result;
|
|
4941
|
-
if (!points.length) break;
|
|
4942
|
-
}
|
|
4943
|
-
return result;
|
|
4944
|
-
}
|
|
4945
|
-
function intersect2(a, b, edge, bbox2) {
|
|
4946
|
-
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;
|
|
4947
|
-
}
|
|
4948
|
-
function bitCode(p, bbox2) {
|
|
4949
|
-
var code = 0;
|
|
4950
|
-
if (p[0] < bbox2[0]) code |= 1;
|
|
4951
|
-
else if (p[0] > bbox2[2]) code |= 2;
|
|
4952
|
-
if (p[1] < bbox2[1]) code |= 4;
|
|
4953
|
-
else if (p[1] > bbox2[3]) code |= 8;
|
|
4954
|
-
return code;
|
|
4955
|
-
}
|
|
4956
|
-
function bboxClip(feature2, bbox2) {
|
|
4957
|
-
const geom = getGeom(feature2);
|
|
4958
|
-
const type = geom.type;
|
|
4959
|
-
const properties = feature2.type === "Feature" ? feature2.properties : {};
|
|
4960
|
-
let coords = geom.coordinates;
|
|
4961
|
-
switch (type) {
|
|
4962
|
-
case "LineString":
|
|
4963
|
-
case "MultiLineString": {
|
|
4964
|
-
const lines = [];
|
|
4965
|
-
if (type === "LineString") {
|
|
4966
|
-
coords = [coords];
|
|
4967
|
-
}
|
|
4968
|
-
coords.forEach((line) => {
|
|
4969
|
-
lineclip(line, bbox2, lines);
|
|
4970
|
-
});
|
|
4971
|
-
if (lines.length === 1) {
|
|
4972
|
-
return lineString(lines[0], properties);
|
|
4973
|
-
}
|
|
4974
|
-
return multiLineString(lines, properties);
|
|
4975
|
-
}
|
|
4976
|
-
case "Polygon":
|
|
4977
|
-
return polygon(clipPolygon(coords, bbox2), properties);
|
|
4978
|
-
case "MultiPolygon":
|
|
4979
|
-
return multiPolygon(
|
|
4980
|
-
coords.map((poly) => {
|
|
4981
|
-
return clipPolygon(poly, bbox2);
|
|
4982
|
-
}),
|
|
4983
|
-
properties
|
|
4984
|
-
);
|
|
4985
|
-
default:
|
|
4986
|
-
throw new Error("geometry " + type + " not supported");
|
|
4987
|
-
}
|
|
4988
|
-
}
|
|
4989
|
-
function clipPolygon(rings, bbox2) {
|
|
4990
|
-
const outRings = [];
|
|
4991
|
-
for (const ring of rings) {
|
|
4992
|
-
const clipped = polygonclip(ring, bbox2);
|
|
4993
|
-
if (clipped.length > 0) {
|
|
4994
|
-
if (clipped[0][0] !== clipped[clipped.length - 1][0] || clipped[0][1] !== clipped[clipped.length - 1][1]) {
|
|
4995
|
-
clipped.push(clipped[0]);
|
|
4996
|
-
}
|
|
4997
|
-
if (clipped.length >= 4) {
|
|
4998
|
-
outRings.push(clipped);
|
|
4999
|
-
}
|
|
5000
|
-
}
|
|
5001
|
-
}
|
|
5002
|
-
return outRings;
|
|
5003
|
-
}
|
|
5004
|
-
var turf_bbox_clip_default = bboxClip;
|
|
5005
|
-
|
|
5006
|
-
// src/filters/tileIntersection.ts
|
|
5007
|
-
function intersectTileGeometry(tileBbox, tileFormat, spatialFilter) {
|
|
5008
|
-
const tilePolygon = turf_bbox_polygon_default(tileBbox);
|
|
5009
|
-
if (!spatialFilter || turf_boolean_within_default(tilePolygon, spatialFilter)) {
|
|
5010
|
-
return true;
|
|
5011
|
-
}
|
|
5012
|
-
const clippedSpatialFilter = turf_intersect_default(
|
|
5013
|
-
featureCollection([tilePolygon, feature(spatialFilter)])
|
|
5014
|
-
);
|
|
5015
|
-
if (!clippedSpatialFilter) {
|
|
5016
|
-
return false;
|
|
5017
|
-
}
|
|
5018
|
-
return tileFormat === "mvt" /* MVT */ ? transformToTileCoords(clippedSpatialFilter.geometry, tileBbox) : clippedSpatialFilter.geometry;
|
|
5019
|
-
}
|
|
5020
|
-
function intersectTileRaster(parent, cellResolution, spatialFilter) {
|
|
5021
|
-
return intersectTileQuadbin(parent, cellResolution, spatialFilter);
|
|
5022
|
-
}
|
|
5023
|
-
function intersectTileQuadbin(parent, cellResolution, spatialFilter) {
|
|
5024
|
-
const tilePolygon = quadbinCellToBoundary(parent);
|
|
5025
|
-
if (!spatialFilter || turf_boolean_within_default(tilePolygon, spatialFilter)) {
|
|
5026
|
-
return true;
|
|
5027
|
-
}
|
|
5028
|
-
const clippedSpatialFilter = turf_intersect_default(
|
|
5029
|
-
featureCollection([feature(tilePolygon), feature(spatialFilter)])
|
|
5030
|
-
);
|
|
5031
|
-
if (!clippedSpatialFilter) {
|
|
5032
|
-
return false;
|
|
5033
|
-
}
|
|
5034
|
-
const cells = quadbinGeometryToCells(
|
|
5035
|
-
clippedSpatialFilter.geometry,
|
|
5036
|
-
cellResolution
|
|
5037
|
-
);
|
|
5038
|
-
return new Set(cells);
|
|
5039
|
-
}
|
|
5040
|
-
var BBOX_WEST = [-180, -90, 0, 90];
|
|
5041
|
-
var BBOX_EAST = [0, -90, 180, 90];
|
|
5042
|
-
function intersectTileH3(cellResolution, spatialFilter) {
|
|
5043
|
-
if (!spatialFilter) {
|
|
5044
|
-
return true;
|
|
5045
|
-
}
|
|
5046
|
-
const spatialFilterFeature = feature(spatialFilter);
|
|
5047
|
-
const cellsWest = h3PolygonToCells(
|
|
5048
|
-
turf_bbox_clip_default(spatialFilterFeature, BBOX_WEST).geometry.coordinates,
|
|
5049
|
-
cellResolution,
|
|
5050
|
-
true
|
|
5051
|
-
);
|
|
5052
|
-
const cellsEast = h3PolygonToCells(
|
|
5053
|
-
turf_bbox_clip_default(spatialFilterFeature, BBOX_EAST).geometry.coordinates,
|
|
5054
|
-
cellResolution,
|
|
5055
|
-
true
|
|
5056
|
-
);
|
|
5057
|
-
return new Set(cellsWest.concat(cellsEast));
|
|
5058
|
-
}
|
|
5059
4880
|
|
|
5060
4881
|
// src/filters/tileFeaturesGeometries.ts
|
|
5061
4882
|
var FEATURE_GEOM_PROPERTY = "__geomValue";
|
|
@@ -5071,45 +4892,55 @@ function tileFeaturesGeometries({
|
|
|
5071
4892
|
if (tile.isVisible === false || !tile.data) {
|
|
5072
4893
|
continue;
|
|
5073
4894
|
}
|
|
5074
|
-
const
|
|
4895
|
+
const bbox2 = [
|
|
5075
4896
|
tile.bbox.west,
|
|
5076
4897
|
tile.bbox.south,
|
|
5077
4898
|
tile.bbox.east,
|
|
5078
4899
|
tile.bbox.north
|
|
5079
4900
|
];
|
|
5080
|
-
const
|
|
5081
|
-
|
|
5082
|
-
|
|
5083
|
-
|
|
4901
|
+
const bboxToGeom = turf_bbox_polygon_default(bbox2);
|
|
4902
|
+
const tileIsFullyVisible = turf_boolean_within_default(bboxToGeom, spatialFilter);
|
|
4903
|
+
const spatialFilterFeature = {
|
|
4904
|
+
type: "Feature",
|
|
4905
|
+
geometry: spatialFilter,
|
|
4906
|
+
properties: {}
|
|
4907
|
+
};
|
|
4908
|
+
const clippedGeometryToIntersect = turf_intersect_default(
|
|
4909
|
+
featureCollection([bboxToGeom, spatialFilterFeature])
|
|
5084
4910
|
);
|
|
5085
|
-
if (
|
|
5086
|
-
|
|
4911
|
+
if (!clippedGeometryToIntersect) {
|
|
4912
|
+
continue;
|
|
4913
|
+
}
|
|
4914
|
+
const transformedGeometryToIntersect = tileFormat === "mvt" /* MVT */ ? transformToTileCoords(clippedGeometryToIntersect.geometry, bbox2) : clippedGeometryToIntersect.geometry;
|
|
5087
4915
|
calculateFeatures({
|
|
5088
4916
|
map,
|
|
5089
|
-
|
|
4917
|
+
tileIsFullyVisible,
|
|
4918
|
+
geometryIntersection: transformedGeometryToIntersect,
|
|
5090
4919
|
data: tile.data.points,
|
|
5091
4920
|
type: "Point",
|
|
5092
|
-
bbox:
|
|
4921
|
+
bbox: bbox2,
|
|
5093
4922
|
tileFormat,
|
|
5094
4923
|
uniqueIdProperty,
|
|
5095
4924
|
options
|
|
5096
4925
|
});
|
|
5097
4926
|
calculateFeatures({
|
|
5098
4927
|
map,
|
|
5099
|
-
|
|
4928
|
+
tileIsFullyVisible,
|
|
4929
|
+
geometryIntersection: transformedGeometryToIntersect,
|
|
5100
4930
|
data: tile.data.lines,
|
|
5101
4931
|
type: "LineString",
|
|
5102
|
-
bbox:
|
|
4932
|
+
bbox: bbox2,
|
|
5103
4933
|
tileFormat,
|
|
5104
4934
|
uniqueIdProperty,
|
|
5105
4935
|
options
|
|
5106
4936
|
});
|
|
5107
4937
|
calculateFeatures({
|
|
5108
4938
|
map,
|
|
5109
|
-
|
|
4939
|
+
tileIsFullyVisible,
|
|
4940
|
+
geometryIntersection: transformedGeometryToIntersect,
|
|
5110
4941
|
data: tile.data.polygons,
|
|
5111
4942
|
type: "Polygon",
|
|
5112
|
-
bbox:
|
|
4943
|
+
bbox: bbox2,
|
|
5113
4944
|
tileFormat,
|
|
5114
4945
|
uniqueIdProperty,
|
|
5115
4946
|
options
|
|
@@ -5127,7 +4958,7 @@ function processTileFeatureProperties({
|
|
|
5127
4958
|
tileFormat,
|
|
5128
4959
|
uniqueIdProperty,
|
|
5129
4960
|
storeGeometry,
|
|
5130
|
-
|
|
4961
|
+
geometryIntersection
|
|
5131
4962
|
}) {
|
|
5132
4963
|
const tileProps = getPropertiesFromTile(data, startIndex);
|
|
5133
4964
|
const uniquePropertyValue = getUniquePropertyValue(
|
|
@@ -5139,7 +4970,7 @@ function processTileFeatureProperties({
|
|
|
5139
4970
|
return;
|
|
5140
4971
|
}
|
|
5141
4972
|
let geometry = null;
|
|
5142
|
-
if (storeGeometry ||
|
|
4973
|
+
if (storeGeometry || geometryIntersection) {
|
|
5143
4974
|
const { positions } = data;
|
|
5144
4975
|
const ringCoordinates = getRingCoordinatesFor(
|
|
5145
4976
|
startIndex,
|
|
@@ -5148,7 +4979,7 @@ function processTileFeatureProperties({
|
|
|
5148
4979
|
);
|
|
5149
4980
|
geometry = getFeatureByType(ringCoordinates, type);
|
|
5150
4981
|
}
|
|
5151
|
-
if (geometry &&
|
|
4982
|
+
if (geometry && geometryIntersection && !turf_boolean_intersects_default(geometry, geometryIntersection)) {
|
|
5152
4983
|
return;
|
|
5153
4984
|
}
|
|
5154
4985
|
const properties = parseProperties(tileProps);
|
|
@@ -5160,7 +4991,7 @@ function processTileFeatureProperties({
|
|
|
5160
4991
|
function addIntersectedFeaturesInTile({
|
|
5161
4992
|
map,
|
|
5162
4993
|
data,
|
|
5163
|
-
|
|
4994
|
+
geometryIntersection,
|
|
5164
4995
|
type,
|
|
5165
4996
|
bbox: bbox2,
|
|
5166
4997
|
tileFormat,
|
|
@@ -5182,7 +5013,7 @@ function addIntersectedFeaturesInTile({
|
|
|
5182
5013
|
tileFormat,
|
|
5183
5014
|
uniqueIdProperty,
|
|
5184
5015
|
storeGeometry,
|
|
5185
|
-
|
|
5016
|
+
geometryIntersection
|
|
5186
5017
|
});
|
|
5187
5018
|
}
|
|
5188
5019
|
}
|
|
@@ -5264,7 +5095,8 @@ function getRingCoordinatesFor(startIndex, endIndex, positions) {
|
|
|
5264
5095
|
}
|
|
5265
5096
|
function calculateFeatures({
|
|
5266
5097
|
map,
|
|
5267
|
-
|
|
5098
|
+
tileIsFullyVisible,
|
|
5099
|
+
geometryIntersection,
|
|
5268
5100
|
data,
|
|
5269
5101
|
type,
|
|
5270
5102
|
bbox: bbox2,
|
|
@@ -5275,7 +5107,7 @@ function calculateFeatures({
|
|
|
5275
5107
|
if (!data?.properties.length) {
|
|
5276
5108
|
return;
|
|
5277
5109
|
}
|
|
5278
|
-
if (
|
|
5110
|
+
if (tileIsFullyVisible) {
|
|
5279
5111
|
addAllFeaturesInTile({
|
|
5280
5112
|
map,
|
|
5281
5113
|
data,
|
|
@@ -5289,7 +5121,7 @@ function calculateFeatures({
|
|
|
5289
5121
|
addIntersectedFeaturesInTile({
|
|
5290
5122
|
map,
|
|
5291
5123
|
data,
|
|
5292
|
-
|
|
5124
|
+
geometryIntersection,
|
|
5293
5125
|
type,
|
|
5294
5126
|
bbox: bbox2,
|
|
5295
5127
|
tileFormat,
|
|
@@ -5339,8 +5171,128 @@ function createIndicesForPoints(data) {
|
|
|
5339
5171
|
}
|
|
5340
5172
|
|
|
5341
5173
|
// src/filters/tileFeaturesSpatialIndex.ts
|
|
5342
|
-
import { getResolution as quadbinGetResolution } from "quadbin";
|
|
5343
|
-
|
|
5174
|
+
import { getResolution as quadbinGetResolution, geometryToCells } from "quadbin";
|
|
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";
|
|
5344
5296
|
function tileFeaturesSpatialIndex({
|
|
5345
5297
|
tiles,
|
|
5346
5298
|
spatialFilter,
|
|
@@ -5349,42 +5301,28 @@ function tileFeaturesSpatialIndex({
|
|
|
5349
5301
|
}) {
|
|
5350
5302
|
const map = /* @__PURE__ */ new Map();
|
|
5351
5303
|
const spatialIndex = getSpatialIndex(spatialDataType);
|
|
5352
|
-
const
|
|
5304
|
+
const resolution = getResolution(tiles, spatialIndex);
|
|
5353
5305
|
const spatialIndexIDName = spatialDataColumn ? spatialDataColumn : spatialIndex;
|
|
5354
|
-
if (!
|
|
5306
|
+
if (!resolution) {
|
|
5355
5307
|
return [];
|
|
5356
5308
|
}
|
|
5357
|
-
|
|
5358
|
-
if (
|
|
5359
|
-
|
|
5309
|
+
const cells = getCellsCoverGeometry(spatialFilter, spatialIndex, resolution);
|
|
5310
|
+
if (!cells?.length) {
|
|
5311
|
+
return [];
|
|
5360
5312
|
}
|
|
5313
|
+
const cellsSet = new Set(cells);
|
|
5361
5314
|
for (const tile of tiles) {
|
|
5362
5315
|
if (tile.isVisible === false || !tile.data) {
|
|
5363
5316
|
continue;
|
|
5364
5317
|
}
|
|
5365
|
-
if (spatialIndex === "quadbin" /* QUADBIN */) {
|
|
5366
|
-
const parent = getTileIndex(tile, spatialIndex);
|
|
5367
|
-
intersection3 = intersectTileQuadbin(
|
|
5368
|
-
parent,
|
|
5369
|
-
cellResolution,
|
|
5370
|
-
spatialFilter
|
|
5371
|
-
);
|
|
5372
|
-
}
|
|
5373
|
-
if (!intersection3) continue;
|
|
5374
5318
|
tile.data.forEach((d) => {
|
|
5375
|
-
if (
|
|
5319
|
+
if (cellsSet.has(d.id)) {
|
|
5376
5320
|
map.set(d.id, { ...d.properties, [spatialIndexIDName]: d.id });
|
|
5377
5321
|
}
|
|
5378
5322
|
});
|
|
5379
5323
|
}
|
|
5380
5324
|
return Array.from(map.values());
|
|
5381
5325
|
}
|
|
5382
|
-
function getTileIndex(tile, spatialIndex) {
|
|
5383
|
-
if (spatialIndex === "quadbin" /* QUADBIN */) {
|
|
5384
|
-
return tile.index.q;
|
|
5385
|
-
}
|
|
5386
|
-
return tile.id;
|
|
5387
|
-
}
|
|
5388
5326
|
function getResolution(tiles, spatialIndex) {
|
|
5389
5327
|
const data = tiles.find((tile) => tile.data?.length)?.data;
|
|
5390
5328
|
if (!data) {
|
|
@@ -5397,6 +5335,26 @@ function getResolution(tiles, spatialIndex) {
|
|
|
5397
5335
|
return h3GetResolution(data[0].id);
|
|
5398
5336
|
}
|
|
5399
5337
|
}
|
|
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
|
+
}
|
|
5400
5358
|
function getSpatialIndex(spatialDataType) {
|
|
5401
5359
|
switch (spatialDataType) {
|
|
5402
5360
|
case "h3":
|
|
@@ -5416,7 +5374,9 @@ var DEFAULT_AGGREGATION_EXP = `1 AS ${DEFAULT_AGGREGATION_EXP_ALIAS}`;
|
|
|
5416
5374
|
// src/filters/tileFeaturesRaster.ts
|
|
5417
5375
|
import {
|
|
5418
5376
|
cellToChildren as _cellToChildren,
|
|
5377
|
+
cellToBoundary,
|
|
5419
5378
|
cellToTile,
|
|
5379
|
+
geometryToCells as geometryToCells2,
|
|
5420
5380
|
getResolution as getResolution2
|
|
5421
5381
|
} from "quadbin";
|
|
5422
5382
|
function tileFeaturesRaster({
|
|
@@ -5435,15 +5395,15 @@ function tileFeaturesRaster({
|
|
|
5435
5395
|
const data = /* @__PURE__ */ new Map();
|
|
5436
5396
|
for (const tile of tiles) {
|
|
5437
5397
|
const parent = tile.index.q;
|
|
5438
|
-
const
|
|
5439
|
-
|
|
5440
|
-
|
|
5441
|
-
options.spatialFilter
|
|
5398
|
+
const tilePolygon = cellToBoundary(parent);
|
|
5399
|
+
const tileFilter = turf_intersect_default(
|
|
5400
|
+
featureCollection([feature(tilePolygon), feature(options.spatialFilter)])
|
|
5442
5401
|
);
|
|
5443
|
-
|
|
5402
|
+
const needsFilter = tileFilter ? !turf_boolean_within_default(tilePolygon, options.spatialFilter) : false;
|
|
5403
|
+
const tileFilterCells = needsFilter ? new Set(geometryToCells2(tileFilter.geometry, cellResolution)) : null;
|
|
5444
5404
|
const tileSortedCells = cellToChildrenSorted(parent, cellResolution);
|
|
5445
5405
|
for (let i = 0; i < tileSortedCells.length; i++) {
|
|
5446
|
-
if (
|
|
5406
|
+
if (needsFilter && !tileFilterCells.has(tileSortedCells[i])) {
|
|
5447
5407
|
continue;
|
|
5448
5408
|
}
|
|
5449
5409
|
const cellData = {};
|
|
@@ -5678,16 +5638,21 @@ function normalizeSortByOptions({
|
|
|
5678
5638
|
});
|
|
5679
5639
|
}
|
|
5680
5640
|
|
|
5641
|
+
// src/widget-sources/constants.ts
|
|
5642
|
+
var OTHERS_CATEGORY_NAME = "_carto_others";
|
|
5643
|
+
|
|
5681
5644
|
// src/operations/groupBy.ts
|
|
5682
5645
|
function groupValuesByColumn({
|
|
5683
5646
|
data,
|
|
5684
5647
|
valuesColumns,
|
|
5685
5648
|
joinOperation,
|
|
5686
5649
|
keysColumn,
|
|
5687
|
-
operation: operation2
|
|
5650
|
+
operation: operation2,
|
|
5651
|
+
othersThreshold,
|
|
5652
|
+
orderBy = "frequency_desc"
|
|
5688
5653
|
}) {
|
|
5689
5654
|
if (Array.isArray(data) && data.length === 0) {
|
|
5690
|
-
return null;
|
|
5655
|
+
return { rows: null };
|
|
5691
5656
|
}
|
|
5692
5657
|
const groups = data.reduce((accumulator, item) => {
|
|
5693
5658
|
const group = item[keysColumn];
|
|
@@ -5702,13 +5667,44 @@ function groupValuesByColumn({
|
|
|
5702
5667
|
return accumulator;
|
|
5703
5668
|
}, /* @__PURE__ */ new Map());
|
|
5704
5669
|
const targetOperation = aggregationFunctions[operation2];
|
|
5705
|
-
if (targetOperation) {
|
|
5706
|
-
return
|
|
5707
|
-
name,
|
|
5708
|
-
value: targetOperation(value)
|
|
5709
|
-
}));
|
|
5670
|
+
if (!targetOperation) {
|
|
5671
|
+
return { rows: [] };
|
|
5710
5672
|
}
|
|
5711
|
-
|
|
5673
|
+
const allCategories = Array.from(groups).map(([name, value]) => ({
|
|
5674
|
+
name,
|
|
5675
|
+
value: targetOperation(value)
|
|
5676
|
+
})).sort(getSorter(orderBy));
|
|
5677
|
+
if (othersThreshold && allCategories.length > othersThreshold) {
|
|
5678
|
+
const otherValue = allCategories.slice(othersThreshold).flatMap(({ name }) => groups.get(name));
|
|
5679
|
+
allCategories.push({
|
|
5680
|
+
name: OTHERS_CATEGORY_NAME,
|
|
5681
|
+
value: targetOperation(otherValue)
|
|
5682
|
+
});
|
|
5683
|
+
return {
|
|
5684
|
+
rows: allCategories,
|
|
5685
|
+
metadata: {
|
|
5686
|
+
others: targetOperation(otherValue)
|
|
5687
|
+
}
|
|
5688
|
+
};
|
|
5689
|
+
}
|
|
5690
|
+
return {
|
|
5691
|
+
rows: allCategories
|
|
5692
|
+
};
|
|
5693
|
+
}
|
|
5694
|
+
function getSorter(orderBy) {
|
|
5695
|
+
switch (orderBy) {
|
|
5696
|
+
case "frequency_asc":
|
|
5697
|
+
return (a, b) => a.value - b.value || localeCompare(a.name, b.name);
|
|
5698
|
+
case "frequency_desc":
|
|
5699
|
+
return (a, b) => b.value - a.value || localeCompare(a.name, b.name);
|
|
5700
|
+
case "alphabetical_asc":
|
|
5701
|
+
return (a, b) => localeCompare(a.name, b.name) || b.value - a.value;
|
|
5702
|
+
case "alphabetical_desc":
|
|
5703
|
+
return (a, b) => localeCompare(b.name, a.name) || b.value - a.value;
|
|
5704
|
+
}
|
|
5705
|
+
}
|
|
5706
|
+
function localeCompare(a, b) {
|
|
5707
|
+
return (a ?? "null").localeCompare(b ?? "null");
|
|
5712
5708
|
}
|
|
5713
5709
|
|
|
5714
5710
|
// src/utils/dateUtils.ts
|
|
@@ -6238,7 +6234,7 @@ var WidgetTilesetSourceImpl = class extends WidgetSource {
|
|
|
6238
6234
|
}
|
|
6239
6235
|
_extractTileFeatures(spatialFilter) {
|
|
6240
6236
|
const prevInputs = this._tileFeatureExtractPreviousInputs;
|
|
6241
|
-
if (this._features.length &&
|
|
6237
|
+
if (this._features.length && prevInputs.spatialFilter && booleanEqual(prevInputs.spatialFilter, spatialFilter)) {
|
|
6242
6238
|
return;
|
|
6243
6239
|
}
|
|
6244
6240
|
this._features = tileFeatures({
|
|
@@ -6327,7 +6323,10 @@ var WidgetTilesetSourceImpl = class extends WidgetSource {
|
|
|
6327
6323
|
joinOperation,
|
|
6328
6324
|
filters,
|
|
6329
6325
|
filterOwner,
|
|
6330
|
-
spatialFilter
|
|
6326
|
+
spatialFilter,
|
|
6327
|
+
othersThreshold,
|
|
6328
|
+
orderBy = "frequency_desc",
|
|
6329
|
+
rawResult
|
|
6331
6330
|
}) {
|
|
6332
6331
|
const filteredFeatures = this._getFilteredFeatures(
|
|
6333
6332
|
spatialFilter,
|
|
@@ -6338,14 +6337,25 @@ var WidgetTilesetSourceImpl = class extends WidgetSource {
|
|
|
6338
6337
|
return [];
|
|
6339
6338
|
}
|
|
6340
6339
|
assertColumn(this._features, column, operationColumn);
|
|
6341
|
-
const
|
|
6340
|
+
const result = groupValuesByColumn({
|
|
6342
6341
|
data: filteredFeatures,
|
|
6343
6342
|
valuesColumns: normalizeColumns(operationColumn || column),
|
|
6344
6343
|
joinOperation,
|
|
6345
6344
|
keysColumn: column,
|
|
6346
|
-
operation: operation2
|
|
6345
|
+
operation: operation2,
|
|
6346
|
+
othersThreshold,
|
|
6347
|
+
orderBy
|
|
6347
6348
|
});
|
|
6348
|
-
|
|
6349
|
+
if (rawResult) {
|
|
6350
|
+
return result;
|
|
6351
|
+
}
|
|
6352
|
+
if (!othersThreshold) {
|
|
6353
|
+
return result?.rows || [];
|
|
6354
|
+
}
|
|
6355
|
+
return [
|
|
6356
|
+
...result?.rows || [],
|
|
6357
|
+
{ name: OTHERS_CATEGORY_NAME, value: result?.metadata?.others }
|
|
6358
|
+
];
|
|
6349
6359
|
}
|
|
6350
6360
|
async getScatter({
|
|
6351
6361
|
xAxisColumn,
|
|
@@ -6478,6 +6488,7 @@ var WidgetTilesetSourceImpl = class extends WidgetSource {
|
|
|
6478
6488
|
* INTERNAL
|
|
6479
6489
|
*/
|
|
6480
6490
|
_getFilteredFeatures(spatialFilter, filters, filterOwner) {
|
|
6491
|
+
assert(spatialFilter, "spatialFilter required for tilesets");
|
|
6481
6492
|
this._extractTileFeatures(spatialFilter);
|
|
6482
6493
|
return applyFilters(
|
|
6483
6494
|
this._features,
|
|
@@ -6501,11 +6512,6 @@ function assertColumn(features, ...columnArgs) {
|
|
|
6501
6512
|
function normalizeColumns(columns) {
|
|
6502
6513
|
return Array.isArray(columns) ? columns : typeof columns === "string" ? [columns] : [];
|
|
6503
6514
|
}
|
|
6504
|
-
function spatialFilterEquals(a, b) {
|
|
6505
|
-
if (a === b) return true;
|
|
6506
|
-
if (!a || !b) return false;
|
|
6507
|
-
return booleanEqual(a, b);
|
|
6508
|
-
}
|
|
6509
6515
|
|
|
6510
6516
|
// src/workers/widget-tileset-worker.ts
|
|
6511
6517
|
var source;
|