@carto/api-client 0.5.7-alpha.6 → 0.5.7
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/CHANGELOG.md +6 -1
- package/build/api-client.cjs +390 -344
- package/build/api-client.cjs.map +1 -1
- package/build/api-client.d.cts +4 -4
- package/build/api-client.d.ts +4 -4
- package/build/api-client.js +378 -334
- package/build/api-client.js.map +1 -1
- package/build/worker-compat.js +729 -688
- package/build/worker-compat.js.map +1 -1
- package/build/worker.js +378 -334
- package/build/worker.js.map +1 -1
- package/package.json +2 -3
- package/src/filters/tileFeatures.ts +1 -1
- package/src/filters/tileFeaturesGeometries.ts +28 -55
- package/src/filters/tileFeaturesRaster.ts +10 -21
- package/src/filters/tileFeaturesSpatialIndex.ts +37 -50
- package/src/filters/tileIntersection.ts +155 -0
- package/src/widget-sources/widget-tileset-source-impl.ts +8 -4
package/build/api-client.cjs
CHANGED
|
@@ -1727,6 +1727,143 @@ init_cjs_shims();
|
|
|
1727
1727
|
// src/filters/tileFeaturesGeometries.ts
|
|
1728
1728
|
init_cjs_shims();
|
|
1729
1729
|
|
|
1730
|
+
// src/utils/transformTileCoordsToWGS84.ts
|
|
1731
|
+
init_cjs_shims();
|
|
1732
|
+
|
|
1733
|
+
// node_modules/@math.gl/core/dist/index.js
|
|
1734
|
+
init_cjs_shims();
|
|
1735
|
+
|
|
1736
|
+
// node_modules/@math.gl/core/dist/lib/common.js
|
|
1737
|
+
init_cjs_shims();
|
|
1738
|
+
var RADIANS_TO_DEGREES = 1 / Math.PI * 180;
|
|
1739
|
+
var DEGREES_TO_RADIANS = 1 / 180 * Math.PI;
|
|
1740
|
+
var DEFAULT_CONFIG = {
|
|
1741
|
+
EPSILON: 1e-12,
|
|
1742
|
+
debug: false,
|
|
1743
|
+
precision: 4,
|
|
1744
|
+
printTypes: false,
|
|
1745
|
+
printDegrees: false,
|
|
1746
|
+
printRowMajor: true,
|
|
1747
|
+
_cartographicRadians: false
|
|
1748
|
+
};
|
|
1749
|
+
globalThis.mathgl = globalThis.mathgl || { config: { ...DEFAULT_CONFIG } };
|
|
1750
|
+
var config = globalThis.mathgl.config;
|
|
1751
|
+
function isArray(value) {
|
|
1752
|
+
return Array.isArray(value) || ArrayBuffer.isView(value) && !(value instanceof DataView);
|
|
1753
|
+
}
|
|
1754
|
+
function lerp(a, b, t) {
|
|
1755
|
+
if (isArray(a)) {
|
|
1756
|
+
return a.map((ai, i) => lerp(ai, b[i], t));
|
|
1757
|
+
}
|
|
1758
|
+
return t * b + (1 - t) * a;
|
|
1759
|
+
}
|
|
1760
|
+
|
|
1761
|
+
// node_modules/@math.gl/web-mercator/dist/index.js
|
|
1762
|
+
init_cjs_shims();
|
|
1763
|
+
|
|
1764
|
+
// node_modules/@math.gl/web-mercator/dist/web-mercator-viewport.js
|
|
1765
|
+
init_cjs_shims();
|
|
1766
|
+
|
|
1767
|
+
// node_modules/@math.gl/web-mercator/dist/math-utils.js
|
|
1768
|
+
init_cjs_shims();
|
|
1769
|
+
|
|
1770
|
+
// node_modules/@math.gl/web-mercator/dist/web-mercator-utils.js
|
|
1771
|
+
init_cjs_shims();
|
|
1772
|
+
|
|
1773
|
+
// node_modules/@math.gl/web-mercator/dist/assert.js
|
|
1774
|
+
init_cjs_shims();
|
|
1775
|
+
function assert(condition, message) {
|
|
1776
|
+
if (!condition) {
|
|
1777
|
+
throw new Error(message || "@math.gl/web-mercator: assertion failed.");
|
|
1778
|
+
}
|
|
1779
|
+
}
|
|
1780
|
+
|
|
1781
|
+
// node_modules/@math.gl/web-mercator/dist/web-mercator-utils.js
|
|
1782
|
+
var PI = Math.PI;
|
|
1783
|
+
var PI_4 = PI / 4;
|
|
1784
|
+
var DEGREES_TO_RADIANS2 = PI / 180;
|
|
1785
|
+
var RADIANS_TO_DEGREES2 = 180 / PI;
|
|
1786
|
+
var TILE_SIZE = 512;
|
|
1787
|
+
function lngLatToWorld(lngLat) {
|
|
1788
|
+
const [lng, lat] = lngLat;
|
|
1789
|
+
assert(Number.isFinite(lng));
|
|
1790
|
+
assert(Number.isFinite(lat) && lat >= -90 && lat <= 90, "invalid latitude");
|
|
1791
|
+
const lambda2 = lng * DEGREES_TO_RADIANS2;
|
|
1792
|
+
const phi2 = lat * DEGREES_TO_RADIANS2;
|
|
1793
|
+
const x = TILE_SIZE * (lambda2 + PI) / (2 * PI);
|
|
1794
|
+
const y = TILE_SIZE * (PI + Math.log(Math.tan(PI_4 + phi2 * 0.5))) / (2 * PI);
|
|
1795
|
+
return [x, y];
|
|
1796
|
+
}
|
|
1797
|
+
function worldToLngLat(xy) {
|
|
1798
|
+
const [x, y] = xy;
|
|
1799
|
+
const lambda2 = x / TILE_SIZE * (2 * PI) - PI;
|
|
1800
|
+
const phi2 = 2 * (Math.atan(Math.exp(y / TILE_SIZE * (2 * PI) - PI)) - PI_4);
|
|
1801
|
+
return [lambda2 * RADIANS_TO_DEGREES2, phi2 * RADIANS_TO_DEGREES2];
|
|
1802
|
+
}
|
|
1803
|
+
|
|
1804
|
+
// node_modules/@math.gl/web-mercator/dist/fit-bounds.js
|
|
1805
|
+
init_cjs_shims();
|
|
1806
|
+
|
|
1807
|
+
// node_modules/@math.gl/web-mercator/dist/get-bounds.js
|
|
1808
|
+
init_cjs_shims();
|
|
1809
|
+
var DEGREES_TO_RADIANS3 = Math.PI / 180;
|
|
1810
|
+
|
|
1811
|
+
// node_modules/@math.gl/web-mercator/dist/normalize-viewport-props.js
|
|
1812
|
+
init_cjs_shims();
|
|
1813
|
+
|
|
1814
|
+
// node_modules/@math.gl/web-mercator/dist/fly-to-viewport.js
|
|
1815
|
+
init_cjs_shims();
|
|
1816
|
+
|
|
1817
|
+
// src/utils/transformTileCoordsToWGS84.ts
|
|
1818
|
+
var TRANSFORM_FN = {
|
|
1819
|
+
Point: transformPoint,
|
|
1820
|
+
MultiPoint: transformMultiPoint,
|
|
1821
|
+
LineString: transformLineString,
|
|
1822
|
+
MultiLineString: transformMultiLineString,
|
|
1823
|
+
Polygon: transformPolygon,
|
|
1824
|
+
MultiPolygon: transformMultiPolygon
|
|
1825
|
+
};
|
|
1826
|
+
function transformTileCoordsToWGS84(geometry, bbox2) {
|
|
1827
|
+
const [west, south, east, north] = bbox2;
|
|
1828
|
+
const nw = lngLatToWorld([west, north]);
|
|
1829
|
+
const se = lngLatToWorld([east, south]);
|
|
1830
|
+
const projectedBbox = [nw, se];
|
|
1831
|
+
if (geometry.type === "GeometryCollection") {
|
|
1832
|
+
throw new Error("Unsupported geometry type GeometryCollection");
|
|
1833
|
+
}
|
|
1834
|
+
const transformFn = TRANSFORM_FN[geometry.type];
|
|
1835
|
+
const coordinates = transformFn(geometry.coordinates, projectedBbox);
|
|
1836
|
+
return { ...geometry, coordinates };
|
|
1837
|
+
}
|
|
1838
|
+
function transformPoint([pointX, pointY], [nw, se]) {
|
|
1839
|
+
const x = lerp(nw[0], se[0], pointX);
|
|
1840
|
+
const y = lerp(nw[1], se[1], pointY);
|
|
1841
|
+
return worldToLngLat([x, y]);
|
|
1842
|
+
}
|
|
1843
|
+
function getPoints(geometry, bbox2) {
|
|
1844
|
+
return geometry.map((g) => transformPoint(g, bbox2));
|
|
1845
|
+
}
|
|
1846
|
+
function transformMultiPoint(multiPoint, bbox2) {
|
|
1847
|
+
return getPoints(multiPoint, bbox2);
|
|
1848
|
+
}
|
|
1849
|
+
function transformLineString(line, bbox2) {
|
|
1850
|
+
return getPoints(line, bbox2);
|
|
1851
|
+
}
|
|
1852
|
+
function transformMultiLineString(multiLineString2, bbox2) {
|
|
1853
|
+
return multiLineString2.map(
|
|
1854
|
+
(lineString2) => transformLineString(lineString2, bbox2)
|
|
1855
|
+
);
|
|
1856
|
+
}
|
|
1857
|
+
function transformPolygon(polygon2, bbox2) {
|
|
1858
|
+
return polygon2.map((polygonRing) => getPoints(polygonRing, bbox2));
|
|
1859
|
+
}
|
|
1860
|
+
function transformMultiPolygon(multiPolygon2, bbox2) {
|
|
1861
|
+
return multiPolygon2.map((polygon2) => transformPolygon(polygon2, bbox2));
|
|
1862
|
+
}
|
|
1863
|
+
|
|
1864
|
+
// src/filters/tileIntersection.ts
|
|
1865
|
+
init_cjs_shims();
|
|
1866
|
+
|
|
1730
1867
|
// node_modules/@turf/bbox-polygon/dist/esm/index.js
|
|
1731
1868
|
init_cjs_shims();
|
|
1732
1869
|
function bboxPolygon(bbox2, options = {}) {
|
|
@@ -2058,7 +2195,7 @@ var MAX_SAFE_INTEGER = 9007199254740991;
|
|
|
2058
2195
|
var POWS_TEN = [1, 10, 100, 1e3, 1e4, 1e5, 1e6, 1e7, 1e8, 1e9, 1e10, 1e11, 1e12, 1e13];
|
|
2059
2196
|
var SQRT_BASE = 1e7;
|
|
2060
2197
|
var MAX = 1e9;
|
|
2061
|
-
function
|
|
2198
|
+
function clone2(configObject) {
|
|
2062
2199
|
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 = {
|
|
2063
2200
|
prefix: "",
|
|
2064
2201
|
groupSize: 3,
|
|
@@ -2184,7 +2321,7 @@ function clone(configObject) {
|
|
|
2184
2321
|
x.c = [x.e = 0];
|
|
2185
2322
|
}
|
|
2186
2323
|
}
|
|
2187
|
-
BigNumber2.clone =
|
|
2324
|
+
BigNumber2.clone = clone2;
|
|
2188
2325
|
BigNumber2.ROUND_UP = 0;
|
|
2189
2326
|
BigNumber2.ROUND_DOWN = 1;
|
|
2190
2327
|
BigNumber2.ROUND_CEIL = 2;
|
|
@@ -3387,7 +3524,7 @@ function toFixedPoint(str, e, z) {
|
|
|
3387
3524
|
}
|
|
3388
3525
|
return str;
|
|
3389
3526
|
}
|
|
3390
|
-
var BigNumber =
|
|
3527
|
+
var BigNumber = clone2();
|
|
3391
3528
|
var bignumber_default = BigNumber;
|
|
3392
3529
|
|
|
3393
3530
|
// node_modules/splaytree-ts/dist/esm/index.js
|
|
@@ -4960,99 +5097,13 @@ var turf_intersect_default = intersect;
|
|
|
4960
5097
|
|
|
4961
5098
|
// src/utils/transformToTileCoords.ts
|
|
4962
5099
|
init_cjs_shims();
|
|
4963
|
-
|
|
4964
|
-
|
|
4965
|
-
|
|
4966
|
-
|
|
4967
|
-
|
|
4968
|
-
|
|
4969
|
-
|
|
4970
|
-
// node_modules/@math.gl/web-mercator/dist/math-utils.js
|
|
4971
|
-
init_cjs_shims();
|
|
4972
|
-
|
|
4973
|
-
// node_modules/@math.gl/core/dist/index.js
|
|
4974
|
-
init_cjs_shims();
|
|
4975
|
-
|
|
4976
|
-
// node_modules/@math.gl/core/dist/lib/common.js
|
|
4977
|
-
init_cjs_shims();
|
|
4978
|
-
var RADIANS_TO_DEGREES = 1 / Math.PI * 180;
|
|
4979
|
-
var DEGREES_TO_RADIANS = 1 / 180 * Math.PI;
|
|
4980
|
-
var DEFAULT_CONFIG = {
|
|
4981
|
-
EPSILON: 1e-12,
|
|
4982
|
-
debug: false,
|
|
4983
|
-
precision: 4,
|
|
4984
|
-
printTypes: false,
|
|
4985
|
-
printDegrees: false,
|
|
4986
|
-
printRowMajor: true,
|
|
4987
|
-
_cartographicRadians: false
|
|
4988
|
-
};
|
|
4989
|
-
globalThis.mathgl = globalThis.mathgl || { config: { ...DEFAULT_CONFIG } };
|
|
4990
|
-
var config = globalThis.mathgl.config;
|
|
4991
|
-
function isArray(value) {
|
|
4992
|
-
return Array.isArray(value) || ArrayBuffer.isView(value) && !(value instanceof DataView);
|
|
4993
|
-
}
|
|
4994
|
-
function lerp(a, b, t) {
|
|
4995
|
-
if (isArray(a)) {
|
|
4996
|
-
return a.map((ai, i) => lerp(ai, b[i], t));
|
|
4997
|
-
}
|
|
4998
|
-
return t * b + (1 - t) * a;
|
|
4999
|
-
}
|
|
5000
|
-
|
|
5001
|
-
// node_modules/@math.gl/web-mercator/dist/web-mercator-utils.js
|
|
5002
|
-
init_cjs_shims();
|
|
5003
|
-
|
|
5004
|
-
// node_modules/@math.gl/web-mercator/dist/assert.js
|
|
5005
|
-
init_cjs_shims();
|
|
5006
|
-
function assert(condition, message) {
|
|
5007
|
-
if (!condition) {
|
|
5008
|
-
throw new Error(message || "@math.gl/web-mercator: assertion failed.");
|
|
5009
|
-
}
|
|
5010
|
-
}
|
|
5011
|
-
|
|
5012
|
-
// node_modules/@math.gl/web-mercator/dist/web-mercator-utils.js
|
|
5013
|
-
var PI = Math.PI;
|
|
5014
|
-
var PI_4 = PI / 4;
|
|
5015
|
-
var DEGREES_TO_RADIANS2 = PI / 180;
|
|
5016
|
-
var RADIANS_TO_DEGREES2 = 180 / PI;
|
|
5017
|
-
var TILE_SIZE = 512;
|
|
5018
|
-
function lngLatToWorld(lngLat) {
|
|
5019
|
-
const [lng, lat] = lngLat;
|
|
5020
|
-
assert(Number.isFinite(lng));
|
|
5021
|
-
assert(Number.isFinite(lat) && lat >= -90 && lat <= 90, "invalid latitude");
|
|
5022
|
-
const lambda2 = lng * DEGREES_TO_RADIANS2;
|
|
5023
|
-
const phi2 = lat * DEGREES_TO_RADIANS2;
|
|
5024
|
-
const x = TILE_SIZE * (lambda2 + PI) / (2 * PI);
|
|
5025
|
-
const y = TILE_SIZE * (PI + Math.log(Math.tan(PI_4 + phi2 * 0.5))) / (2 * PI);
|
|
5026
|
-
return [x, y];
|
|
5027
|
-
}
|
|
5028
|
-
function worldToLngLat(xy) {
|
|
5029
|
-
const [x, y] = xy;
|
|
5030
|
-
const lambda2 = x / TILE_SIZE * (2 * PI) - PI;
|
|
5031
|
-
const phi2 = 2 * (Math.atan(Math.exp(y / TILE_SIZE * (2 * PI) - PI)) - PI_4);
|
|
5032
|
-
return [lambda2 * RADIANS_TO_DEGREES2, phi2 * RADIANS_TO_DEGREES2];
|
|
5033
|
-
}
|
|
5034
|
-
|
|
5035
|
-
// node_modules/@math.gl/web-mercator/dist/fit-bounds.js
|
|
5036
|
-
init_cjs_shims();
|
|
5037
|
-
|
|
5038
|
-
// node_modules/@math.gl/web-mercator/dist/get-bounds.js
|
|
5039
|
-
init_cjs_shims();
|
|
5040
|
-
var DEGREES_TO_RADIANS3 = Math.PI / 180;
|
|
5041
|
-
|
|
5042
|
-
// node_modules/@math.gl/web-mercator/dist/normalize-viewport-props.js
|
|
5043
|
-
init_cjs_shims();
|
|
5044
|
-
|
|
5045
|
-
// node_modules/@math.gl/web-mercator/dist/fly-to-viewport.js
|
|
5046
|
-
init_cjs_shims();
|
|
5047
|
-
|
|
5048
|
-
// src/utils/transformToTileCoords.ts
|
|
5049
|
-
var TRANSFORM_FN = {
|
|
5050
|
-
Point: transformPoint,
|
|
5051
|
-
MultiPoint: transformMultiPoint,
|
|
5052
|
-
LineString: transformLineString,
|
|
5053
|
-
MultiLineString: transformMultiLineString,
|
|
5054
|
-
Polygon: transformPolygon,
|
|
5055
|
-
MultiPolygon: transformMultiPolygon
|
|
5100
|
+
var TRANSFORM_FN2 = {
|
|
5101
|
+
Point: transformPoint2,
|
|
5102
|
+
MultiPoint: transformMultiPoint2,
|
|
5103
|
+
LineString: transformLineString2,
|
|
5104
|
+
MultiLineString: transformMultiLineString2,
|
|
5105
|
+
Polygon: transformPolygon2,
|
|
5106
|
+
MultiPolygon: transformMultiPolygon2
|
|
5056
5107
|
};
|
|
5057
5108
|
function transformToTileCoords(geometry, bbox2) {
|
|
5058
5109
|
const [west, south, east, north] = bbox2;
|
|
@@ -5062,34 +5113,34 @@ function transformToTileCoords(geometry, bbox2) {
|
|
|
5062
5113
|
if (geometry.type === "GeometryCollection") {
|
|
5063
5114
|
throw new Error("Unsupported geometry type GeometryCollection");
|
|
5064
5115
|
}
|
|
5065
|
-
const transformFn =
|
|
5116
|
+
const transformFn = TRANSFORM_FN2[geometry.type];
|
|
5066
5117
|
const coordinates = transformFn(geometry.coordinates, projectedBbox);
|
|
5067
5118
|
return { ...geometry, coordinates };
|
|
5068
5119
|
}
|
|
5069
|
-
function
|
|
5120
|
+
function transformPoint2([pointX, pointY], [nw, se]) {
|
|
5070
5121
|
const x = inverseLerp(nw[0], se[0], pointX);
|
|
5071
5122
|
const y = inverseLerp(nw[1], se[1], pointY);
|
|
5072
5123
|
return [x, y];
|
|
5073
5124
|
}
|
|
5074
|
-
function
|
|
5075
|
-
return geometry.map((g) =>
|
|
5125
|
+
function getPoints2(geometry, bbox2) {
|
|
5126
|
+
return geometry.map((g) => transformPoint2(projectFlat(g), bbox2));
|
|
5076
5127
|
}
|
|
5077
|
-
function
|
|
5078
|
-
return
|
|
5128
|
+
function transformMultiPoint2(multiPoint, bbox2) {
|
|
5129
|
+
return getPoints2(multiPoint, bbox2);
|
|
5079
5130
|
}
|
|
5080
|
-
function
|
|
5081
|
-
return
|
|
5131
|
+
function transformLineString2(line, bbox2) {
|
|
5132
|
+
return getPoints2(line, bbox2);
|
|
5082
5133
|
}
|
|
5083
|
-
function
|
|
5134
|
+
function transformMultiLineString2(multiLineString2, bbox2) {
|
|
5084
5135
|
return multiLineString2.map(
|
|
5085
|
-
(lineString2) =>
|
|
5136
|
+
(lineString2) => transformLineString2(lineString2, bbox2)
|
|
5086
5137
|
);
|
|
5087
5138
|
}
|
|
5088
|
-
function
|
|
5089
|
-
return polygon2.map((polygonRing) =>
|
|
5090
|
-
}
|
|
5091
|
-
function
|
|
5092
|
-
return multiPolygon2.map((polygon2) =>
|
|
5139
|
+
function transformPolygon2(polygon2, bbox2) {
|
|
5140
|
+
return polygon2.map((polygonRing) => getPoints2(polygonRing, bbox2));
|
|
5141
|
+
}
|
|
5142
|
+
function transformMultiPolygon2(multiPolygon2, bbox2) {
|
|
5143
|
+
return multiPolygon2.map((polygon2) => transformPolygon2(polygon2, bbox2));
|
|
5093
5144
|
}
|
|
5094
5145
|
function projectFlat(xyz) {
|
|
5095
5146
|
return lngLatToWorld(xyz);
|
|
@@ -5098,52 +5149,181 @@ function inverseLerp(a, b, x) {
|
|
|
5098
5149
|
return (x - a) / (b - a);
|
|
5099
5150
|
}
|
|
5100
5151
|
|
|
5101
|
-
// src/
|
|
5152
|
+
// src/filters/tileIntersection.ts
|
|
5153
|
+
var import_quadbin = require("quadbin");
|
|
5154
|
+
var import_h3_js = require("h3-js");
|
|
5155
|
+
|
|
5156
|
+
// node_modules/@turf/bbox-clip/dist/esm/index.js
|
|
5102
5157
|
init_cjs_shims();
|
|
5103
|
-
|
|
5104
|
-
|
|
5105
|
-
|
|
5106
|
-
|
|
5107
|
-
|
|
5108
|
-
|
|
5109
|
-
|
|
5110
|
-
|
|
5111
|
-
|
|
5112
|
-
|
|
5113
|
-
|
|
5114
|
-
|
|
5115
|
-
|
|
5116
|
-
|
|
5117
|
-
|
|
5158
|
+
function lineclip(points, bbox2, result) {
|
|
5159
|
+
var len = points.length, codeA = bitCode(points[0], bbox2), part = [], i, codeB, lastCode;
|
|
5160
|
+
let a;
|
|
5161
|
+
let b;
|
|
5162
|
+
if (!result) result = [];
|
|
5163
|
+
for (i = 1; i < len; i++) {
|
|
5164
|
+
a = points[i - 1];
|
|
5165
|
+
b = points[i];
|
|
5166
|
+
codeB = lastCode = bitCode(b, bbox2);
|
|
5167
|
+
while (true) {
|
|
5168
|
+
if (!(codeA | codeB)) {
|
|
5169
|
+
part.push(a);
|
|
5170
|
+
if (codeB !== lastCode) {
|
|
5171
|
+
part.push(b);
|
|
5172
|
+
if (i < len - 1) {
|
|
5173
|
+
result.push(part);
|
|
5174
|
+
part = [];
|
|
5175
|
+
}
|
|
5176
|
+
} else if (i === len - 1) {
|
|
5177
|
+
part.push(b);
|
|
5178
|
+
}
|
|
5179
|
+
break;
|
|
5180
|
+
} else if (codeA & codeB) {
|
|
5181
|
+
break;
|
|
5182
|
+
} else if (codeA) {
|
|
5183
|
+
a = intersect2(a, b, codeA, bbox2);
|
|
5184
|
+
codeA = bitCode(a, bbox2);
|
|
5185
|
+
} else {
|
|
5186
|
+
b = intersect2(a, b, codeB, bbox2);
|
|
5187
|
+
codeB = bitCode(b, bbox2);
|
|
5188
|
+
}
|
|
5189
|
+
}
|
|
5190
|
+
codeA = lastCode;
|
|
5118
5191
|
}
|
|
5119
|
-
|
|
5120
|
-
|
|
5121
|
-
return { ...geometry, coordinates };
|
|
5192
|
+
if (part.length) result.push(part);
|
|
5193
|
+
return result;
|
|
5122
5194
|
}
|
|
5123
|
-
function
|
|
5124
|
-
|
|
5125
|
-
|
|
5126
|
-
|
|
5195
|
+
function polygonclip(points, bbox2) {
|
|
5196
|
+
var result, edge, prev, prevInside, i, p, inside;
|
|
5197
|
+
for (edge = 1; edge <= 8; edge *= 2) {
|
|
5198
|
+
result = [];
|
|
5199
|
+
prev = points[points.length - 1];
|
|
5200
|
+
prevInside = !(bitCode(prev, bbox2) & edge);
|
|
5201
|
+
for (i = 0; i < points.length; i++) {
|
|
5202
|
+
p = points[i];
|
|
5203
|
+
inside = !(bitCode(p, bbox2) & edge);
|
|
5204
|
+
if (inside !== prevInside) result.push(intersect2(prev, p, edge, bbox2));
|
|
5205
|
+
if (inside) result.push(p);
|
|
5206
|
+
prev = p;
|
|
5207
|
+
prevInside = inside;
|
|
5208
|
+
}
|
|
5209
|
+
points = result;
|
|
5210
|
+
if (!points.length) break;
|
|
5211
|
+
}
|
|
5212
|
+
return result;
|
|
5127
5213
|
}
|
|
5128
|
-
function
|
|
5129
|
-
return
|
|
5214
|
+
function intersect2(a, b, edge, bbox2) {
|
|
5215
|
+
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;
|
|
5130
5216
|
}
|
|
5131
|
-
function
|
|
5132
|
-
|
|
5217
|
+
function bitCode(p, bbox2) {
|
|
5218
|
+
var code = 0;
|
|
5219
|
+
if (p[0] < bbox2[0]) code |= 1;
|
|
5220
|
+
else if (p[0] > bbox2[2]) code |= 2;
|
|
5221
|
+
if (p[1] < bbox2[1]) code |= 4;
|
|
5222
|
+
else if (p[1] > bbox2[3]) code |= 8;
|
|
5223
|
+
return code;
|
|
5133
5224
|
}
|
|
5134
|
-
function
|
|
5135
|
-
|
|
5225
|
+
function bboxClip(feature2, bbox2) {
|
|
5226
|
+
const geom = getGeom(feature2);
|
|
5227
|
+
const type = geom.type;
|
|
5228
|
+
const properties = feature2.type === "Feature" ? feature2.properties : {};
|
|
5229
|
+
let coords = geom.coordinates;
|
|
5230
|
+
switch (type) {
|
|
5231
|
+
case "LineString":
|
|
5232
|
+
case "MultiLineString": {
|
|
5233
|
+
const lines = [];
|
|
5234
|
+
if (type === "LineString") {
|
|
5235
|
+
coords = [coords];
|
|
5236
|
+
}
|
|
5237
|
+
coords.forEach((line) => {
|
|
5238
|
+
lineclip(line, bbox2, lines);
|
|
5239
|
+
});
|
|
5240
|
+
if (lines.length === 1) {
|
|
5241
|
+
return lineString(lines[0], properties);
|
|
5242
|
+
}
|
|
5243
|
+
return multiLineString(lines, properties);
|
|
5244
|
+
}
|
|
5245
|
+
case "Polygon":
|
|
5246
|
+
return polygon(clipPolygon(coords, bbox2), properties);
|
|
5247
|
+
case "MultiPolygon":
|
|
5248
|
+
return multiPolygon(
|
|
5249
|
+
coords.map((poly) => {
|
|
5250
|
+
return clipPolygon(poly, bbox2);
|
|
5251
|
+
}),
|
|
5252
|
+
properties
|
|
5253
|
+
);
|
|
5254
|
+
default:
|
|
5255
|
+
throw new Error("geometry " + type + " not supported");
|
|
5256
|
+
}
|
|
5136
5257
|
}
|
|
5137
|
-
function
|
|
5138
|
-
|
|
5139
|
-
|
|
5258
|
+
function clipPolygon(rings, bbox2) {
|
|
5259
|
+
const outRings = [];
|
|
5260
|
+
for (const ring of rings) {
|
|
5261
|
+
const clipped = polygonclip(ring, bbox2);
|
|
5262
|
+
if (clipped.length > 0) {
|
|
5263
|
+
if (clipped[0][0] !== clipped[clipped.length - 1][0] || clipped[0][1] !== clipped[clipped.length - 1][1]) {
|
|
5264
|
+
clipped.push(clipped[0]);
|
|
5265
|
+
}
|
|
5266
|
+
if (clipped.length >= 4) {
|
|
5267
|
+
outRings.push(clipped);
|
|
5268
|
+
}
|
|
5269
|
+
}
|
|
5270
|
+
}
|
|
5271
|
+
return outRings;
|
|
5272
|
+
}
|
|
5273
|
+
var turf_bbox_clip_default = bboxClip;
|
|
5274
|
+
|
|
5275
|
+
// src/filters/tileIntersection.ts
|
|
5276
|
+
function intersectTileGeometry(tileBbox, tileFormat, spatialFilter) {
|
|
5277
|
+
const tilePolygon = turf_bbox_polygon_default(tileBbox);
|
|
5278
|
+
if (!spatialFilter || turf_boolean_within_default(tilePolygon, spatialFilter)) {
|
|
5279
|
+
return true;
|
|
5280
|
+
}
|
|
5281
|
+
const clippedSpatialFilter = turf_intersect_default(
|
|
5282
|
+
featureCollection([tilePolygon, feature(spatialFilter)])
|
|
5140
5283
|
);
|
|
5284
|
+
if (!clippedSpatialFilter) {
|
|
5285
|
+
return false;
|
|
5286
|
+
}
|
|
5287
|
+
return tileFormat === "mvt" /* MVT */ ? transformToTileCoords(clippedSpatialFilter.geometry, tileBbox) : clippedSpatialFilter.geometry;
|
|
5141
5288
|
}
|
|
5142
|
-
function
|
|
5143
|
-
return
|
|
5289
|
+
function intersectTileRaster(parent, cellResolution, spatialFilter) {
|
|
5290
|
+
return intersectTileQuadbin(parent, cellResolution, spatialFilter);
|
|
5144
5291
|
}
|
|
5145
|
-
function
|
|
5146
|
-
|
|
5292
|
+
function intersectTileQuadbin(parent, cellResolution, spatialFilter) {
|
|
5293
|
+
const tilePolygon = (0, import_quadbin.cellToBoundary)(parent);
|
|
5294
|
+
if (!spatialFilter || turf_boolean_within_default(tilePolygon, spatialFilter)) {
|
|
5295
|
+
return true;
|
|
5296
|
+
}
|
|
5297
|
+
const clippedSpatialFilter = turf_intersect_default(
|
|
5298
|
+
featureCollection([feature(tilePolygon), feature(spatialFilter)])
|
|
5299
|
+
);
|
|
5300
|
+
if (!clippedSpatialFilter) {
|
|
5301
|
+
return false;
|
|
5302
|
+
}
|
|
5303
|
+
const cells = (0, import_quadbin.geometryToCells)(
|
|
5304
|
+
clippedSpatialFilter.geometry,
|
|
5305
|
+
cellResolution
|
|
5306
|
+
);
|
|
5307
|
+
return new Set(cells);
|
|
5308
|
+
}
|
|
5309
|
+
var BBOX_WEST = [-180, -90, 0, 90];
|
|
5310
|
+
var BBOX_EAST = [0, -90, 180, 90];
|
|
5311
|
+
function intersectTileH3(cellResolution, spatialFilter) {
|
|
5312
|
+
if (!spatialFilter) {
|
|
5313
|
+
return true;
|
|
5314
|
+
}
|
|
5315
|
+
const spatialFilterFeature = feature(spatialFilter);
|
|
5316
|
+
const cellsWest = (0, import_h3_js.polygonToCells)(
|
|
5317
|
+
turf_bbox_clip_default(spatialFilterFeature, BBOX_WEST).geometry.coordinates,
|
|
5318
|
+
cellResolution,
|
|
5319
|
+
true
|
|
5320
|
+
);
|
|
5321
|
+
const cellsEast = (0, import_h3_js.polygonToCells)(
|
|
5322
|
+
turf_bbox_clip_default(spatialFilterFeature, BBOX_EAST).geometry.coordinates,
|
|
5323
|
+
cellResolution,
|
|
5324
|
+
true
|
|
5325
|
+
);
|
|
5326
|
+
return new Set(cellsWest.concat(cellsEast));
|
|
5147
5327
|
}
|
|
5148
5328
|
|
|
5149
5329
|
// src/filters/tileFeaturesGeometries.ts
|
|
@@ -5160,55 +5340,45 @@ function tileFeaturesGeometries({
|
|
|
5160
5340
|
if (tile.isVisible === false || !tile.data) {
|
|
5161
5341
|
continue;
|
|
5162
5342
|
}
|
|
5163
|
-
const
|
|
5343
|
+
const tileBbox = [
|
|
5164
5344
|
tile.bbox.west,
|
|
5165
5345
|
tile.bbox.south,
|
|
5166
5346
|
tile.bbox.east,
|
|
5167
5347
|
tile.bbox.north
|
|
5168
5348
|
];
|
|
5169
|
-
const
|
|
5170
|
-
|
|
5171
|
-
|
|
5172
|
-
|
|
5173
|
-
geometry: spatialFilter,
|
|
5174
|
-
properties: {}
|
|
5175
|
-
};
|
|
5176
|
-
const clippedGeometryToIntersect = turf_intersect_default(
|
|
5177
|
-
featureCollection([bboxToGeom, spatialFilterFeature])
|
|
5349
|
+
const intersection3 = intersectTileGeometry(
|
|
5350
|
+
tileBbox,
|
|
5351
|
+
tileFormat,
|
|
5352
|
+
spatialFilter
|
|
5178
5353
|
);
|
|
5179
|
-
if (
|
|
5180
|
-
|
|
5181
|
-
}
|
|
5182
|
-
const transformedGeometryToIntersect = tileFormat === "mvt" /* MVT */ ? transformToTileCoords(clippedGeometryToIntersect.geometry, bbox2) : clippedGeometryToIntersect.geometry;
|
|
5354
|
+
if (intersection3 === false) continue;
|
|
5355
|
+
const transformedSpatialFilter = intersection3 === true ? void 0 : intersection3;
|
|
5183
5356
|
calculateFeatures({
|
|
5184
5357
|
map,
|
|
5185
|
-
|
|
5186
|
-
geometryIntersection: transformedGeometryToIntersect,
|
|
5358
|
+
spatialFilter: transformedSpatialFilter,
|
|
5187
5359
|
data: tile.data.points,
|
|
5188
5360
|
type: "Point",
|
|
5189
|
-
bbox:
|
|
5361
|
+
bbox: tileBbox,
|
|
5190
5362
|
tileFormat,
|
|
5191
5363
|
uniqueIdProperty,
|
|
5192
5364
|
options
|
|
5193
5365
|
});
|
|
5194
5366
|
calculateFeatures({
|
|
5195
5367
|
map,
|
|
5196
|
-
|
|
5197
|
-
geometryIntersection: transformedGeometryToIntersect,
|
|
5368
|
+
spatialFilter: transformedSpatialFilter,
|
|
5198
5369
|
data: tile.data.lines,
|
|
5199
5370
|
type: "LineString",
|
|
5200
|
-
bbox:
|
|
5371
|
+
bbox: tileBbox,
|
|
5201
5372
|
tileFormat,
|
|
5202
5373
|
uniqueIdProperty,
|
|
5203
5374
|
options
|
|
5204
5375
|
});
|
|
5205
5376
|
calculateFeatures({
|
|
5206
5377
|
map,
|
|
5207
|
-
|
|
5208
|
-
geometryIntersection: transformedGeometryToIntersect,
|
|
5378
|
+
spatialFilter: transformedSpatialFilter,
|
|
5209
5379
|
data: tile.data.polygons,
|
|
5210
5380
|
type: "Polygon",
|
|
5211
|
-
bbox:
|
|
5381
|
+
bbox: tileBbox,
|
|
5212
5382
|
tileFormat,
|
|
5213
5383
|
uniqueIdProperty,
|
|
5214
5384
|
options
|
|
@@ -5226,7 +5396,7 @@ function processTileFeatureProperties({
|
|
|
5226
5396
|
tileFormat,
|
|
5227
5397
|
uniqueIdProperty,
|
|
5228
5398
|
storeGeometry,
|
|
5229
|
-
|
|
5399
|
+
spatialFilter
|
|
5230
5400
|
}) {
|
|
5231
5401
|
const tileProps = getPropertiesFromTile(data, startIndex);
|
|
5232
5402
|
const uniquePropertyValue = getUniquePropertyValue(
|
|
@@ -5238,7 +5408,7 @@ function processTileFeatureProperties({
|
|
|
5238
5408
|
return;
|
|
5239
5409
|
}
|
|
5240
5410
|
let geometry = null;
|
|
5241
|
-
if (storeGeometry ||
|
|
5411
|
+
if (storeGeometry || spatialFilter) {
|
|
5242
5412
|
const { positions } = data;
|
|
5243
5413
|
const ringCoordinates = getRingCoordinatesFor(
|
|
5244
5414
|
startIndex,
|
|
@@ -5247,7 +5417,7 @@ function processTileFeatureProperties({
|
|
|
5247
5417
|
);
|
|
5248
5418
|
geometry = getFeatureByType(ringCoordinates, type);
|
|
5249
5419
|
}
|
|
5250
|
-
if (geometry &&
|
|
5420
|
+
if (geometry && spatialFilter && !turf_boolean_intersects_default(geometry, spatialFilter)) {
|
|
5251
5421
|
return;
|
|
5252
5422
|
}
|
|
5253
5423
|
const properties = parseProperties(tileProps);
|
|
@@ -5259,7 +5429,7 @@ function processTileFeatureProperties({
|
|
|
5259
5429
|
function addIntersectedFeaturesInTile({
|
|
5260
5430
|
map,
|
|
5261
5431
|
data,
|
|
5262
|
-
|
|
5432
|
+
spatialFilter,
|
|
5263
5433
|
type,
|
|
5264
5434
|
bbox: bbox2,
|
|
5265
5435
|
tileFormat,
|
|
@@ -5281,7 +5451,7 @@ function addIntersectedFeaturesInTile({
|
|
|
5281
5451
|
tileFormat,
|
|
5282
5452
|
uniqueIdProperty,
|
|
5283
5453
|
storeGeometry,
|
|
5284
|
-
|
|
5454
|
+
spatialFilter
|
|
5285
5455
|
});
|
|
5286
5456
|
}
|
|
5287
5457
|
}
|
|
@@ -5363,8 +5533,7 @@ function getRingCoordinatesFor(startIndex, endIndex, positions) {
|
|
|
5363
5533
|
}
|
|
5364
5534
|
function calculateFeatures({
|
|
5365
5535
|
map,
|
|
5366
|
-
|
|
5367
|
-
geometryIntersection,
|
|
5536
|
+
spatialFilter,
|
|
5368
5537
|
data,
|
|
5369
5538
|
type,
|
|
5370
5539
|
bbox: bbox2,
|
|
@@ -5375,7 +5544,7 @@ function calculateFeatures({
|
|
|
5375
5544
|
if (!data?.properties.length) {
|
|
5376
5545
|
return;
|
|
5377
5546
|
}
|
|
5378
|
-
if (
|
|
5547
|
+
if (!spatialFilter) {
|
|
5379
5548
|
addAllFeaturesInTile({
|
|
5380
5549
|
map,
|
|
5381
5550
|
data,
|
|
@@ -5389,7 +5558,7 @@ function calculateFeatures({
|
|
|
5389
5558
|
addIntersectedFeaturesInTile({
|
|
5390
5559
|
map,
|
|
5391
5560
|
data,
|
|
5392
|
-
|
|
5561
|
+
spatialFilter,
|
|
5393
5562
|
type,
|
|
5394
5563
|
bbox: bbox2,
|
|
5395
5564
|
tileFormat,
|
|
@@ -5440,129 +5609,8 @@ function createIndicesForPoints(data) {
|
|
|
5440
5609
|
|
|
5441
5610
|
// src/filters/tileFeaturesSpatialIndex.ts
|
|
5442
5611
|
init_cjs_shims();
|
|
5443
|
-
var
|
|
5444
|
-
|
|
5445
|
-
// node_modules/@turf/bbox-clip/dist/esm/index.js
|
|
5446
|
-
init_cjs_shims();
|
|
5447
|
-
function lineclip(points, bbox2, result) {
|
|
5448
|
-
var len = points.length, codeA = bitCode(points[0], bbox2), part = [], i, codeB, lastCode;
|
|
5449
|
-
let a;
|
|
5450
|
-
let b;
|
|
5451
|
-
if (!result) result = [];
|
|
5452
|
-
for (i = 1; i < len; i++) {
|
|
5453
|
-
a = points[i - 1];
|
|
5454
|
-
b = points[i];
|
|
5455
|
-
codeB = lastCode = bitCode(b, bbox2);
|
|
5456
|
-
while (true) {
|
|
5457
|
-
if (!(codeA | codeB)) {
|
|
5458
|
-
part.push(a);
|
|
5459
|
-
if (codeB !== lastCode) {
|
|
5460
|
-
part.push(b);
|
|
5461
|
-
if (i < len - 1) {
|
|
5462
|
-
result.push(part);
|
|
5463
|
-
part = [];
|
|
5464
|
-
}
|
|
5465
|
-
} else if (i === len - 1) {
|
|
5466
|
-
part.push(b);
|
|
5467
|
-
}
|
|
5468
|
-
break;
|
|
5469
|
-
} else if (codeA & codeB) {
|
|
5470
|
-
break;
|
|
5471
|
-
} else if (codeA) {
|
|
5472
|
-
a = intersect2(a, b, codeA, bbox2);
|
|
5473
|
-
codeA = bitCode(a, bbox2);
|
|
5474
|
-
} else {
|
|
5475
|
-
b = intersect2(a, b, codeB, bbox2);
|
|
5476
|
-
codeB = bitCode(b, bbox2);
|
|
5477
|
-
}
|
|
5478
|
-
}
|
|
5479
|
-
codeA = lastCode;
|
|
5480
|
-
}
|
|
5481
|
-
if (part.length) result.push(part);
|
|
5482
|
-
return result;
|
|
5483
|
-
}
|
|
5484
|
-
function polygonclip(points, bbox2) {
|
|
5485
|
-
var result, edge, prev, prevInside, i, p, inside;
|
|
5486
|
-
for (edge = 1; edge <= 8; edge *= 2) {
|
|
5487
|
-
result = [];
|
|
5488
|
-
prev = points[points.length - 1];
|
|
5489
|
-
prevInside = !(bitCode(prev, bbox2) & edge);
|
|
5490
|
-
for (i = 0; i < points.length; i++) {
|
|
5491
|
-
p = points[i];
|
|
5492
|
-
inside = !(bitCode(p, bbox2) & edge);
|
|
5493
|
-
if (inside !== prevInside) result.push(intersect2(prev, p, edge, bbox2));
|
|
5494
|
-
if (inside) result.push(p);
|
|
5495
|
-
prev = p;
|
|
5496
|
-
prevInside = inside;
|
|
5497
|
-
}
|
|
5498
|
-
points = result;
|
|
5499
|
-
if (!points.length) break;
|
|
5500
|
-
}
|
|
5501
|
-
return result;
|
|
5502
|
-
}
|
|
5503
|
-
function intersect2(a, b, edge, bbox2) {
|
|
5504
|
-
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;
|
|
5505
|
-
}
|
|
5506
|
-
function bitCode(p, bbox2) {
|
|
5507
|
-
var code = 0;
|
|
5508
|
-
if (p[0] < bbox2[0]) code |= 1;
|
|
5509
|
-
else if (p[0] > bbox2[2]) code |= 2;
|
|
5510
|
-
if (p[1] < bbox2[1]) code |= 4;
|
|
5511
|
-
else if (p[1] > bbox2[3]) code |= 8;
|
|
5512
|
-
return code;
|
|
5513
|
-
}
|
|
5514
|
-
function bboxClip(feature2, bbox2) {
|
|
5515
|
-
const geom = getGeom(feature2);
|
|
5516
|
-
const type = geom.type;
|
|
5517
|
-
const properties = feature2.type === "Feature" ? feature2.properties : {};
|
|
5518
|
-
let coords = geom.coordinates;
|
|
5519
|
-
switch (type) {
|
|
5520
|
-
case "LineString":
|
|
5521
|
-
case "MultiLineString": {
|
|
5522
|
-
const lines = [];
|
|
5523
|
-
if (type === "LineString") {
|
|
5524
|
-
coords = [coords];
|
|
5525
|
-
}
|
|
5526
|
-
coords.forEach((line) => {
|
|
5527
|
-
lineclip(line, bbox2, lines);
|
|
5528
|
-
});
|
|
5529
|
-
if (lines.length === 1) {
|
|
5530
|
-
return lineString(lines[0], properties);
|
|
5531
|
-
}
|
|
5532
|
-
return multiLineString(lines, properties);
|
|
5533
|
-
}
|
|
5534
|
-
case "Polygon":
|
|
5535
|
-
return polygon(clipPolygon(coords, bbox2), properties);
|
|
5536
|
-
case "MultiPolygon":
|
|
5537
|
-
return multiPolygon(
|
|
5538
|
-
coords.map((poly) => {
|
|
5539
|
-
return clipPolygon(poly, bbox2);
|
|
5540
|
-
}),
|
|
5541
|
-
properties
|
|
5542
|
-
);
|
|
5543
|
-
default:
|
|
5544
|
-
throw new Error("geometry " + type + " not supported");
|
|
5545
|
-
}
|
|
5546
|
-
}
|
|
5547
|
-
function clipPolygon(rings, bbox2) {
|
|
5548
|
-
const outRings = [];
|
|
5549
|
-
for (const ring of rings) {
|
|
5550
|
-
const clipped = polygonclip(ring, bbox2);
|
|
5551
|
-
if (clipped.length > 0) {
|
|
5552
|
-
if (clipped[0][0] !== clipped[clipped.length - 1][0] || clipped[0][1] !== clipped[clipped.length - 1][1]) {
|
|
5553
|
-
clipped.push(clipped[0]);
|
|
5554
|
-
}
|
|
5555
|
-
if (clipped.length >= 4) {
|
|
5556
|
-
outRings.push(clipped);
|
|
5557
|
-
}
|
|
5558
|
-
}
|
|
5559
|
-
}
|
|
5560
|
-
return outRings;
|
|
5561
|
-
}
|
|
5562
|
-
var turf_bbox_clip_default = bboxClip;
|
|
5563
|
-
|
|
5564
|
-
// src/filters/tileFeaturesSpatialIndex.ts
|
|
5565
|
-
var import_h3_js = require("h3-js");
|
|
5612
|
+
var import_quadbin2 = require("quadbin");
|
|
5613
|
+
var import_h3_js2 = require("h3-js");
|
|
5566
5614
|
function tileFeaturesSpatialIndex({
|
|
5567
5615
|
tiles,
|
|
5568
5616
|
spatialFilter,
|
|
@@ -5571,58 +5619,52 @@ function tileFeaturesSpatialIndex({
|
|
|
5571
5619
|
}) {
|
|
5572
5620
|
const map = /* @__PURE__ */ new Map();
|
|
5573
5621
|
const spatialIndex = getSpatialIndex(spatialDataType);
|
|
5574
|
-
const
|
|
5622
|
+
const cellResolution = getResolution(tiles, spatialIndex);
|
|
5575
5623
|
const spatialIndexIDName = spatialDataColumn ? spatialDataColumn : spatialIndex;
|
|
5576
|
-
if (!
|
|
5624
|
+
if (!cellResolution) {
|
|
5577
5625
|
return [];
|
|
5578
5626
|
}
|
|
5579
|
-
|
|
5580
|
-
if (
|
|
5581
|
-
|
|
5627
|
+
let intersection3;
|
|
5628
|
+
if (spatialIndex === "h3" /* H3 */) {
|
|
5629
|
+
intersection3 = intersectTileH3(cellResolution, spatialFilter);
|
|
5582
5630
|
}
|
|
5583
|
-
const cellsSet = new Set(cells);
|
|
5584
5631
|
for (const tile of tiles) {
|
|
5585
5632
|
if (tile.isVisible === false || !tile.data) {
|
|
5586
5633
|
continue;
|
|
5587
5634
|
}
|
|
5635
|
+
if (spatialIndex === "quadbin" /* QUADBIN */) {
|
|
5636
|
+
const parent = getTileIndex(tile, spatialIndex);
|
|
5637
|
+
intersection3 = intersectTileQuadbin(
|
|
5638
|
+
parent,
|
|
5639
|
+
cellResolution,
|
|
5640
|
+
spatialFilter
|
|
5641
|
+
);
|
|
5642
|
+
}
|
|
5643
|
+
if (!intersection3) continue;
|
|
5588
5644
|
tile.data.forEach((d) => {
|
|
5589
|
-
if (
|
|
5645
|
+
if (intersection3 === true || intersection3.has(d.id)) {
|
|
5590
5646
|
map.set(d.id, { ...d.properties, [spatialIndexIDName]: d.id });
|
|
5591
5647
|
}
|
|
5592
5648
|
});
|
|
5593
5649
|
}
|
|
5594
5650
|
return Array.from(map.values());
|
|
5595
5651
|
}
|
|
5652
|
+
function getTileIndex(tile, spatialIndex) {
|
|
5653
|
+
if (spatialIndex === "quadbin" /* QUADBIN */) {
|
|
5654
|
+
return tile.index.q;
|
|
5655
|
+
}
|
|
5656
|
+
return tile.id;
|
|
5657
|
+
}
|
|
5596
5658
|
function getResolution(tiles, spatialIndex) {
|
|
5597
5659
|
const data = tiles.find((tile) => tile.data?.length)?.data;
|
|
5598
5660
|
if (!data) {
|
|
5599
5661
|
return;
|
|
5600
5662
|
}
|
|
5601
5663
|
if (spatialIndex === "quadbin" /* QUADBIN */) {
|
|
5602
|
-
return Number((0,
|
|
5603
|
-
}
|
|
5604
|
-
if (spatialIndex === "h3" /* H3 */) {
|
|
5605
|
-
return (0, import_h3_js.getResolution)(data[0].id);
|
|
5606
|
-
}
|
|
5607
|
-
}
|
|
5608
|
-
var bboxWest = [-180, -90, 0, 90];
|
|
5609
|
-
var bboxEast = [0, -90, 180, 90];
|
|
5610
|
-
function getCellsCoverGeometry(geometry, spatialIndex, resolution) {
|
|
5611
|
-
if (spatialIndex === "quadbin" /* QUADBIN */) {
|
|
5612
|
-
return (0, import_quadbin.geometryToCells)(geometry, resolution);
|
|
5664
|
+
return Number((0, import_quadbin2.getResolution)(data[0].id));
|
|
5613
5665
|
}
|
|
5614
5666
|
if (spatialIndex === "h3" /* H3 */) {
|
|
5615
|
-
return (0,
|
|
5616
|
-
turf_bbox_clip_default(geometry, bboxWest).geometry.coordinates,
|
|
5617
|
-
resolution,
|
|
5618
|
-
true
|
|
5619
|
-
).concat(
|
|
5620
|
-
(0, import_h3_js.polygonToCells)(
|
|
5621
|
-
turf_bbox_clip_default(geometry, bboxEast).geometry.coordinates,
|
|
5622
|
-
resolution,
|
|
5623
|
-
true
|
|
5624
|
-
)
|
|
5625
|
-
);
|
|
5667
|
+
return (0, import_h3_js2.getResolution)(data[0].id);
|
|
5626
5668
|
}
|
|
5627
5669
|
}
|
|
5628
5670
|
function getSpatialIndex(spatialDataType) {
|
|
@@ -5650,7 +5692,7 @@ var DEFAULT_AGGREGATION_EXP = `1 AS ${DEFAULT_AGGREGATION_EXP_ALIAS}`;
|
|
|
5650
5692
|
|
|
5651
5693
|
// src/filters/tileFeaturesRaster.ts
|
|
5652
5694
|
init_cjs_shims();
|
|
5653
|
-
var
|
|
5695
|
+
var import_quadbin3 = require("quadbin");
|
|
5654
5696
|
function tileFeaturesRaster({
|
|
5655
5697
|
tiles,
|
|
5656
5698
|
...options
|
|
@@ -5661,21 +5703,21 @@ function tileFeaturesRaster({
|
|
|
5661
5703
|
}
|
|
5662
5704
|
tiles = tiles.filter(isRasterTileVisible);
|
|
5663
5705
|
if (tiles.length === 0) return [];
|
|
5664
|
-
const tileResolution = (0,
|
|
5706
|
+
const tileResolution = (0, import_quadbin3.getResolution)(tiles[0].index.q);
|
|
5665
5707
|
const tileBlockSize = tiles[0].data.blockSize;
|
|
5666
5708
|
const cellResolution = tileResolution + BigInt(Math.log2(tileBlockSize));
|
|
5667
5709
|
const data = /* @__PURE__ */ new Map();
|
|
5668
5710
|
for (const tile of tiles) {
|
|
5669
5711
|
const parent = tile.index.q;
|
|
5670
|
-
const
|
|
5671
|
-
|
|
5672
|
-
|
|
5712
|
+
const intersection3 = intersectTileRaster(
|
|
5713
|
+
parent,
|
|
5714
|
+
cellResolution,
|
|
5715
|
+
options.spatialFilter
|
|
5673
5716
|
);
|
|
5674
|
-
|
|
5675
|
-
const tileFilterCells = needsFilter ? new Set((0, import_quadbin2.geometryToCells)(tileFilter.geometry, cellResolution)) : null;
|
|
5717
|
+
if (intersection3 === false) continue;
|
|
5676
5718
|
const tileSortedCells = cellToChildrenSorted(parent, cellResolution);
|
|
5677
5719
|
for (let i = 0; i < tileSortedCells.length; i++) {
|
|
5678
|
-
if (
|
|
5720
|
+
if (intersection3 !== true && !intersection3.has(tileSortedCells[i])) {
|
|
5679
5721
|
continue;
|
|
5680
5722
|
}
|
|
5681
5723
|
const cellData = {};
|
|
@@ -5702,10 +5744,10 @@ function isRasterTileVisible(tile) {
|
|
|
5702
5744
|
return !!(tile.isVisible && tile.data?.cells?.numericProps);
|
|
5703
5745
|
}
|
|
5704
5746
|
function cellToChildrenSorted(parent, resolution) {
|
|
5705
|
-
return (0,
|
|
5747
|
+
return (0, import_quadbin3.cellToChildren)(parent, resolution).sort(
|
|
5706
5748
|
(cellA, cellB) => {
|
|
5707
|
-
const tileA = (0,
|
|
5708
|
-
const tileB = (0,
|
|
5749
|
+
const tileA = (0, import_quadbin3.cellToTile)(cellA);
|
|
5750
|
+
const tileB = (0, import_quadbin3.cellToTile)(cellB);
|
|
5709
5751
|
if (tileA.y !== tileB.y) {
|
|
5710
5752
|
return tileA.y > tileB.y ? 1 : -1;
|
|
5711
5753
|
}
|
|
@@ -7466,7 +7508,7 @@ var WidgetTilesetSourceImpl = class extends WidgetSource {
|
|
|
7466
7508
|
}
|
|
7467
7509
|
_extractTileFeatures(spatialFilter) {
|
|
7468
7510
|
const prevInputs = this._tileFeatureExtractPreviousInputs;
|
|
7469
|
-
if (this._features.length &&
|
|
7511
|
+
if (this._features.length && spatialFilterEquals(prevInputs.spatialFilter, spatialFilter)) {
|
|
7470
7512
|
return;
|
|
7471
7513
|
}
|
|
7472
7514
|
this._features = tileFeatures({
|
|
@@ -7706,7 +7748,6 @@ var WidgetTilesetSourceImpl = class extends WidgetSource {
|
|
|
7706
7748
|
* INTERNAL
|
|
7707
7749
|
*/
|
|
7708
7750
|
_getFilteredFeatures(spatialFilter, filters, filterOwner) {
|
|
7709
|
-
assert2(spatialFilter, "spatialFilter required for tilesets");
|
|
7710
7751
|
this._extractTileFeatures(spatialFilter);
|
|
7711
7752
|
return applyFilters(
|
|
7712
7753
|
this._features,
|
|
@@ -7730,6 +7771,11 @@ function assertColumn(features, ...columnArgs) {
|
|
|
7730
7771
|
function normalizeColumns(columns) {
|
|
7731
7772
|
return Array.isArray(columns) ? columns : typeof columns === "string" ? [columns] : [];
|
|
7732
7773
|
}
|
|
7774
|
+
function spatialFilterEquals(a, b) {
|
|
7775
|
+
if (a === b) return true;
|
|
7776
|
+
if (!a || !b) return false;
|
|
7777
|
+
return booleanEqual(a, b);
|
|
7778
|
+
}
|
|
7733
7779
|
|
|
7734
7780
|
// src/widget-sources/widget-tileset-source.ts
|
|
7735
7781
|
var WidgetTilesetSource = class extends WidgetSource {
|