@carto/api-client 0.5.6 → 0.5.7-alpha-optional-spatial-filter.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 +454 -344
- package/build/api-client.cjs.map +1 -1
- package/build/api-client.d.cts +23 -5
- package/build/api-client.d.ts +23 -5
- package/build/api-client.js +415 -308
- package/build/api-client.js.map +1 -1
- package/build/worker-compat.js +4169 -2962
- package/build/worker-compat.js.map +1 -1
- package/build/worker.js +384 -334
- package/build/worker.js.map +1 -1
- package/package.json +2 -2
- package/src/filters/tileFeatures.ts +1 -1
- package/src/filters/tileFeaturesGeometries.ts +28 -55
- package/src/filters/tileFeaturesRaster.ts +16 -12
- package/src/filters/tileFeaturesSpatialIndex.ts +37 -50
- package/src/filters/tileIntersection.ts +155 -0
- package/src/index.ts +1 -0
- package/src/utils/CellSet.ts +90 -0
- package/src/widget-sources/widget-tileset-source-impl.ts +8 -4
package/build/api-client.cjs
CHANGED
|
@@ -103,6 +103,7 @@ __export(src_exports, {
|
|
|
103
103
|
ApiVersion: () => ApiVersion,
|
|
104
104
|
BASEMAP: () => basemap_styles_default,
|
|
105
105
|
CartoAPIError: () => CartoAPIError,
|
|
106
|
+
CellSet: () => CellSet,
|
|
106
107
|
DEFAULT_API_BASE_URL: () => DEFAULT_API_BASE_URL,
|
|
107
108
|
FEATURE_GEOM_PROPERTY: () => FEATURE_GEOM_PROPERTY,
|
|
108
109
|
FilterType: () => FilterType,
|
|
@@ -1726,6 +1727,143 @@ init_cjs_shims();
|
|
|
1726
1727
|
// src/filters/tileFeaturesGeometries.ts
|
|
1727
1728
|
init_cjs_shims();
|
|
1728
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
|
+
|
|
1729
1867
|
// node_modules/@turf/bbox-polygon/dist/esm/index.js
|
|
1730
1868
|
init_cjs_shims();
|
|
1731
1869
|
function bboxPolygon(bbox2, options = {}) {
|
|
@@ -2057,7 +2195,7 @@ var MAX_SAFE_INTEGER = 9007199254740991;
|
|
|
2057
2195
|
var POWS_TEN = [1, 10, 100, 1e3, 1e4, 1e5, 1e6, 1e7, 1e8, 1e9, 1e10, 1e11, 1e12, 1e13];
|
|
2058
2196
|
var SQRT_BASE = 1e7;
|
|
2059
2197
|
var MAX = 1e9;
|
|
2060
|
-
function
|
|
2198
|
+
function clone2(configObject) {
|
|
2061
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 = {
|
|
2062
2200
|
prefix: "",
|
|
2063
2201
|
groupSize: 3,
|
|
@@ -2183,7 +2321,7 @@ function clone(configObject) {
|
|
|
2183
2321
|
x.c = [x.e = 0];
|
|
2184
2322
|
}
|
|
2185
2323
|
}
|
|
2186
|
-
BigNumber2.clone =
|
|
2324
|
+
BigNumber2.clone = clone2;
|
|
2187
2325
|
BigNumber2.ROUND_UP = 0;
|
|
2188
2326
|
BigNumber2.ROUND_DOWN = 1;
|
|
2189
2327
|
BigNumber2.ROUND_CEIL = 2;
|
|
@@ -3386,7 +3524,7 @@ function toFixedPoint(str, e, z) {
|
|
|
3386
3524
|
}
|
|
3387
3525
|
return str;
|
|
3388
3526
|
}
|
|
3389
|
-
var BigNumber =
|
|
3527
|
+
var BigNumber = clone2();
|
|
3390
3528
|
var bignumber_default = BigNumber;
|
|
3391
3529
|
|
|
3392
3530
|
// node_modules/splaytree-ts/dist/esm/index.js
|
|
@@ -4959,99 +5097,13 @@ var turf_intersect_default = intersect;
|
|
|
4959
5097
|
|
|
4960
5098
|
// src/utils/transformToTileCoords.ts
|
|
4961
5099
|
init_cjs_shims();
|
|
4962
|
-
|
|
4963
|
-
|
|
4964
|
-
|
|
4965
|
-
|
|
4966
|
-
|
|
4967
|
-
|
|
4968
|
-
|
|
4969
|
-
// node_modules/@math.gl/web-mercator/dist/math-utils.js
|
|
4970
|
-
init_cjs_shims();
|
|
4971
|
-
|
|
4972
|
-
// node_modules/@math.gl/core/dist/index.js
|
|
4973
|
-
init_cjs_shims();
|
|
4974
|
-
|
|
4975
|
-
// node_modules/@math.gl/core/dist/lib/common.js
|
|
4976
|
-
init_cjs_shims();
|
|
4977
|
-
var RADIANS_TO_DEGREES = 1 / Math.PI * 180;
|
|
4978
|
-
var DEGREES_TO_RADIANS = 1 / 180 * Math.PI;
|
|
4979
|
-
var DEFAULT_CONFIG = {
|
|
4980
|
-
EPSILON: 1e-12,
|
|
4981
|
-
debug: false,
|
|
4982
|
-
precision: 4,
|
|
4983
|
-
printTypes: false,
|
|
4984
|
-
printDegrees: false,
|
|
4985
|
-
printRowMajor: true,
|
|
4986
|
-
_cartographicRadians: false
|
|
4987
|
-
};
|
|
4988
|
-
globalThis.mathgl = globalThis.mathgl || { config: { ...DEFAULT_CONFIG } };
|
|
4989
|
-
var config = globalThis.mathgl.config;
|
|
4990
|
-
function isArray(value) {
|
|
4991
|
-
return Array.isArray(value) || ArrayBuffer.isView(value) && !(value instanceof DataView);
|
|
4992
|
-
}
|
|
4993
|
-
function lerp(a, b, t) {
|
|
4994
|
-
if (isArray(a)) {
|
|
4995
|
-
return a.map((ai, i) => lerp(ai, b[i], t));
|
|
4996
|
-
}
|
|
4997
|
-
return t * b + (1 - t) * a;
|
|
4998
|
-
}
|
|
4999
|
-
|
|
5000
|
-
// node_modules/@math.gl/web-mercator/dist/web-mercator-utils.js
|
|
5001
|
-
init_cjs_shims();
|
|
5002
|
-
|
|
5003
|
-
// node_modules/@math.gl/web-mercator/dist/assert.js
|
|
5004
|
-
init_cjs_shims();
|
|
5005
|
-
function assert(condition, message) {
|
|
5006
|
-
if (!condition) {
|
|
5007
|
-
throw new Error(message || "@math.gl/web-mercator: assertion failed.");
|
|
5008
|
-
}
|
|
5009
|
-
}
|
|
5010
|
-
|
|
5011
|
-
// node_modules/@math.gl/web-mercator/dist/web-mercator-utils.js
|
|
5012
|
-
var PI = Math.PI;
|
|
5013
|
-
var PI_4 = PI / 4;
|
|
5014
|
-
var DEGREES_TO_RADIANS2 = PI / 180;
|
|
5015
|
-
var RADIANS_TO_DEGREES2 = 180 / PI;
|
|
5016
|
-
var TILE_SIZE = 512;
|
|
5017
|
-
function lngLatToWorld(lngLat) {
|
|
5018
|
-
const [lng, lat] = lngLat;
|
|
5019
|
-
assert(Number.isFinite(lng));
|
|
5020
|
-
assert(Number.isFinite(lat) && lat >= -90 && lat <= 90, "invalid latitude");
|
|
5021
|
-
const lambda2 = lng * DEGREES_TO_RADIANS2;
|
|
5022
|
-
const phi2 = lat * DEGREES_TO_RADIANS2;
|
|
5023
|
-
const x = TILE_SIZE * (lambda2 + PI) / (2 * PI);
|
|
5024
|
-
const y = TILE_SIZE * (PI + Math.log(Math.tan(PI_4 + phi2 * 0.5))) / (2 * PI);
|
|
5025
|
-
return [x, y];
|
|
5026
|
-
}
|
|
5027
|
-
function worldToLngLat(xy) {
|
|
5028
|
-
const [x, y] = xy;
|
|
5029
|
-
const lambda2 = x / TILE_SIZE * (2 * PI) - PI;
|
|
5030
|
-
const phi2 = 2 * (Math.atan(Math.exp(y / TILE_SIZE * (2 * PI) - PI)) - PI_4);
|
|
5031
|
-
return [lambda2 * RADIANS_TO_DEGREES2, phi2 * RADIANS_TO_DEGREES2];
|
|
5032
|
-
}
|
|
5033
|
-
|
|
5034
|
-
// node_modules/@math.gl/web-mercator/dist/fit-bounds.js
|
|
5035
|
-
init_cjs_shims();
|
|
5036
|
-
|
|
5037
|
-
// node_modules/@math.gl/web-mercator/dist/get-bounds.js
|
|
5038
|
-
init_cjs_shims();
|
|
5039
|
-
var DEGREES_TO_RADIANS3 = Math.PI / 180;
|
|
5040
|
-
|
|
5041
|
-
// node_modules/@math.gl/web-mercator/dist/normalize-viewport-props.js
|
|
5042
|
-
init_cjs_shims();
|
|
5043
|
-
|
|
5044
|
-
// node_modules/@math.gl/web-mercator/dist/fly-to-viewport.js
|
|
5045
|
-
init_cjs_shims();
|
|
5046
|
-
|
|
5047
|
-
// src/utils/transformToTileCoords.ts
|
|
5048
|
-
var TRANSFORM_FN = {
|
|
5049
|
-
Point: transformPoint,
|
|
5050
|
-
MultiPoint: transformMultiPoint,
|
|
5051
|
-
LineString: transformLineString,
|
|
5052
|
-
MultiLineString: transformMultiLineString,
|
|
5053
|
-
Polygon: transformPolygon,
|
|
5054
|
-
MultiPolygon: transformMultiPolygon
|
|
5100
|
+
var TRANSFORM_FN2 = {
|
|
5101
|
+
Point: transformPoint2,
|
|
5102
|
+
MultiPoint: transformMultiPoint2,
|
|
5103
|
+
LineString: transformLineString2,
|
|
5104
|
+
MultiLineString: transformMultiLineString2,
|
|
5105
|
+
Polygon: transformPolygon2,
|
|
5106
|
+
MultiPolygon: transformMultiPolygon2
|
|
5055
5107
|
};
|
|
5056
5108
|
function transformToTileCoords(geometry, bbox2) {
|
|
5057
5109
|
const [west, south, east, north] = bbox2;
|
|
@@ -5061,34 +5113,34 @@ function transformToTileCoords(geometry, bbox2) {
|
|
|
5061
5113
|
if (geometry.type === "GeometryCollection") {
|
|
5062
5114
|
throw new Error("Unsupported geometry type GeometryCollection");
|
|
5063
5115
|
}
|
|
5064
|
-
const transformFn =
|
|
5116
|
+
const transformFn = TRANSFORM_FN2[geometry.type];
|
|
5065
5117
|
const coordinates = transformFn(geometry.coordinates, projectedBbox);
|
|
5066
5118
|
return { ...geometry, coordinates };
|
|
5067
5119
|
}
|
|
5068
|
-
function
|
|
5120
|
+
function transformPoint2([pointX, pointY], [nw, se]) {
|
|
5069
5121
|
const x = inverseLerp(nw[0], se[0], pointX);
|
|
5070
5122
|
const y = inverseLerp(nw[1], se[1], pointY);
|
|
5071
5123
|
return [x, y];
|
|
5072
5124
|
}
|
|
5073
|
-
function
|
|
5074
|
-
return geometry.map((g) =>
|
|
5125
|
+
function getPoints2(geometry, bbox2) {
|
|
5126
|
+
return geometry.map((g) => transformPoint2(projectFlat(g), bbox2));
|
|
5075
5127
|
}
|
|
5076
|
-
function
|
|
5077
|
-
return
|
|
5128
|
+
function transformMultiPoint2(multiPoint, bbox2) {
|
|
5129
|
+
return getPoints2(multiPoint, bbox2);
|
|
5078
5130
|
}
|
|
5079
|
-
function
|
|
5080
|
-
return
|
|
5131
|
+
function transformLineString2(line, bbox2) {
|
|
5132
|
+
return getPoints2(line, bbox2);
|
|
5081
5133
|
}
|
|
5082
|
-
function
|
|
5134
|
+
function transformMultiLineString2(multiLineString2, bbox2) {
|
|
5083
5135
|
return multiLineString2.map(
|
|
5084
|
-
(lineString2) =>
|
|
5136
|
+
(lineString2) => transformLineString2(lineString2, bbox2)
|
|
5085
5137
|
);
|
|
5086
5138
|
}
|
|
5087
|
-
function
|
|
5088
|
-
return polygon2.map((polygonRing) =>
|
|
5139
|
+
function transformPolygon2(polygon2, bbox2) {
|
|
5140
|
+
return polygon2.map((polygonRing) => getPoints2(polygonRing, bbox2));
|
|
5089
5141
|
}
|
|
5090
|
-
function
|
|
5091
|
-
return multiPolygon2.map((polygon2) =>
|
|
5142
|
+
function transformMultiPolygon2(multiPolygon2, bbox2) {
|
|
5143
|
+
return multiPolygon2.map((polygon2) => transformPolygon2(polygon2, bbox2));
|
|
5092
5144
|
}
|
|
5093
5145
|
function projectFlat(xyz) {
|
|
5094
5146
|
return lngLatToWorld(xyz);
|
|
@@ -5097,52 +5149,181 @@ function inverseLerp(a, b, x) {
|
|
|
5097
5149
|
return (x - a) / (b - a);
|
|
5098
5150
|
}
|
|
5099
5151
|
|
|
5100
|
-
// 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
|
|
5101
5157
|
init_cjs_shims();
|
|
5102
|
-
|
|
5103
|
-
|
|
5104
|
-
|
|
5105
|
-
|
|
5106
|
-
|
|
5107
|
-
|
|
5108
|
-
|
|
5109
|
-
|
|
5110
|
-
|
|
5111
|
-
|
|
5112
|
-
|
|
5113
|
-
|
|
5114
|
-
|
|
5115
|
-
|
|
5116
|
-
|
|
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;
|
|
5191
|
+
}
|
|
5192
|
+
if (part.length) result.push(part);
|
|
5193
|
+
return result;
|
|
5194
|
+
}
|
|
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;
|
|
5117
5211
|
}
|
|
5118
|
-
|
|
5119
|
-
const coordinates = transformFn(geometry.coordinates, projectedBbox);
|
|
5120
|
-
return { ...geometry, coordinates };
|
|
5212
|
+
return result;
|
|
5121
5213
|
}
|
|
5122
|
-
function
|
|
5123
|
-
|
|
5124
|
-
const y = lerp(nw[1], se[1], pointY);
|
|
5125
|
-
return worldToLngLat([x, y]);
|
|
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;
|
|
5126
5216
|
}
|
|
5127
|
-
function
|
|
5128
|
-
|
|
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;
|
|
5129
5224
|
}
|
|
5130
|
-
function
|
|
5131
|
-
|
|
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
|
+
}
|
|
5132
5257
|
}
|
|
5133
|
-
function
|
|
5134
|
-
|
|
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;
|
|
5135
5272
|
}
|
|
5136
|
-
|
|
5137
|
-
|
|
5138
|
-
|
|
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)])
|
|
5139
5283
|
);
|
|
5284
|
+
if (!clippedSpatialFilter) {
|
|
5285
|
+
return false;
|
|
5286
|
+
}
|
|
5287
|
+
return tileFormat === "mvt" /* MVT */ ? transformToTileCoords(clippedSpatialFilter.geometry, tileBbox) : clippedSpatialFilter.geometry;
|
|
5140
5288
|
}
|
|
5141
|
-
function
|
|
5142
|
-
return
|
|
5289
|
+
function intersectTileRaster(parent, cellResolution, spatialFilter) {
|
|
5290
|
+
return intersectTileQuadbin(parent, cellResolution, spatialFilter);
|
|
5143
5291
|
}
|
|
5144
|
-
function
|
|
5145
|
-
|
|
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));
|
|
5146
5327
|
}
|
|
5147
5328
|
|
|
5148
5329
|
// src/filters/tileFeaturesGeometries.ts
|
|
@@ -5159,55 +5340,45 @@ function tileFeaturesGeometries({
|
|
|
5159
5340
|
if (tile.isVisible === false || !tile.data) {
|
|
5160
5341
|
continue;
|
|
5161
5342
|
}
|
|
5162
|
-
const
|
|
5343
|
+
const tileBbox = [
|
|
5163
5344
|
tile.bbox.west,
|
|
5164
5345
|
tile.bbox.south,
|
|
5165
5346
|
tile.bbox.east,
|
|
5166
5347
|
tile.bbox.north
|
|
5167
5348
|
];
|
|
5168
|
-
const
|
|
5169
|
-
|
|
5170
|
-
|
|
5171
|
-
|
|
5172
|
-
geometry: spatialFilter,
|
|
5173
|
-
properties: {}
|
|
5174
|
-
};
|
|
5175
|
-
const clippedGeometryToIntersect = turf_intersect_default(
|
|
5176
|
-
featureCollection([bboxToGeom, spatialFilterFeature])
|
|
5349
|
+
const intersection3 = intersectTileGeometry(
|
|
5350
|
+
tileBbox,
|
|
5351
|
+
tileFormat,
|
|
5352
|
+
spatialFilter
|
|
5177
5353
|
);
|
|
5178
|
-
if (
|
|
5179
|
-
|
|
5180
|
-
}
|
|
5181
|
-
const transformedGeometryToIntersect = tileFormat === "mvt" /* MVT */ ? transformToTileCoords(clippedGeometryToIntersect.geometry, bbox2) : clippedGeometryToIntersect.geometry;
|
|
5354
|
+
if (intersection3 === false) continue;
|
|
5355
|
+
const transformedSpatialFilter = intersection3 === true ? void 0 : intersection3;
|
|
5182
5356
|
calculateFeatures({
|
|
5183
5357
|
map,
|
|
5184
|
-
|
|
5185
|
-
geometryIntersection: transformedGeometryToIntersect,
|
|
5358
|
+
spatialFilter: transformedSpatialFilter,
|
|
5186
5359
|
data: tile.data.points,
|
|
5187
5360
|
type: "Point",
|
|
5188
|
-
bbox:
|
|
5361
|
+
bbox: tileBbox,
|
|
5189
5362
|
tileFormat,
|
|
5190
5363
|
uniqueIdProperty,
|
|
5191
5364
|
options
|
|
5192
5365
|
});
|
|
5193
5366
|
calculateFeatures({
|
|
5194
5367
|
map,
|
|
5195
|
-
|
|
5196
|
-
geometryIntersection: transformedGeometryToIntersect,
|
|
5368
|
+
spatialFilter: transformedSpatialFilter,
|
|
5197
5369
|
data: tile.data.lines,
|
|
5198
5370
|
type: "LineString",
|
|
5199
|
-
bbox:
|
|
5371
|
+
bbox: tileBbox,
|
|
5200
5372
|
tileFormat,
|
|
5201
5373
|
uniqueIdProperty,
|
|
5202
5374
|
options
|
|
5203
5375
|
});
|
|
5204
5376
|
calculateFeatures({
|
|
5205
5377
|
map,
|
|
5206
|
-
|
|
5207
|
-
geometryIntersection: transformedGeometryToIntersect,
|
|
5378
|
+
spatialFilter: transformedSpatialFilter,
|
|
5208
5379
|
data: tile.data.polygons,
|
|
5209
5380
|
type: "Polygon",
|
|
5210
|
-
bbox:
|
|
5381
|
+
bbox: tileBbox,
|
|
5211
5382
|
tileFormat,
|
|
5212
5383
|
uniqueIdProperty,
|
|
5213
5384
|
options
|
|
@@ -5225,7 +5396,7 @@ function processTileFeatureProperties({
|
|
|
5225
5396
|
tileFormat,
|
|
5226
5397
|
uniqueIdProperty,
|
|
5227
5398
|
storeGeometry,
|
|
5228
|
-
|
|
5399
|
+
spatialFilter
|
|
5229
5400
|
}) {
|
|
5230
5401
|
const tileProps = getPropertiesFromTile(data, startIndex);
|
|
5231
5402
|
const uniquePropertyValue = getUniquePropertyValue(
|
|
@@ -5237,7 +5408,7 @@ function processTileFeatureProperties({
|
|
|
5237
5408
|
return;
|
|
5238
5409
|
}
|
|
5239
5410
|
let geometry = null;
|
|
5240
|
-
if (storeGeometry ||
|
|
5411
|
+
if (storeGeometry || spatialFilter) {
|
|
5241
5412
|
const { positions } = data;
|
|
5242
5413
|
const ringCoordinates = getRingCoordinatesFor(
|
|
5243
5414
|
startIndex,
|
|
@@ -5246,7 +5417,7 @@ function processTileFeatureProperties({
|
|
|
5246
5417
|
);
|
|
5247
5418
|
geometry = getFeatureByType(ringCoordinates, type);
|
|
5248
5419
|
}
|
|
5249
|
-
if (geometry &&
|
|
5420
|
+
if (geometry && spatialFilter && !turf_boolean_intersects_default(geometry, spatialFilter)) {
|
|
5250
5421
|
return;
|
|
5251
5422
|
}
|
|
5252
5423
|
const properties = parseProperties(tileProps);
|
|
@@ -5258,7 +5429,7 @@ function processTileFeatureProperties({
|
|
|
5258
5429
|
function addIntersectedFeaturesInTile({
|
|
5259
5430
|
map,
|
|
5260
5431
|
data,
|
|
5261
|
-
|
|
5432
|
+
spatialFilter,
|
|
5262
5433
|
type,
|
|
5263
5434
|
bbox: bbox2,
|
|
5264
5435
|
tileFormat,
|
|
@@ -5280,7 +5451,7 @@ function addIntersectedFeaturesInTile({
|
|
|
5280
5451
|
tileFormat,
|
|
5281
5452
|
uniqueIdProperty,
|
|
5282
5453
|
storeGeometry,
|
|
5283
|
-
|
|
5454
|
+
spatialFilter
|
|
5284
5455
|
});
|
|
5285
5456
|
}
|
|
5286
5457
|
}
|
|
@@ -5362,8 +5533,7 @@ function getRingCoordinatesFor(startIndex, endIndex, positions) {
|
|
|
5362
5533
|
}
|
|
5363
5534
|
function calculateFeatures({
|
|
5364
5535
|
map,
|
|
5365
|
-
|
|
5366
|
-
geometryIntersection,
|
|
5536
|
+
spatialFilter,
|
|
5367
5537
|
data,
|
|
5368
5538
|
type,
|
|
5369
5539
|
bbox: bbox2,
|
|
@@ -5374,7 +5544,7 @@ function calculateFeatures({
|
|
|
5374
5544
|
if (!data?.properties.length) {
|
|
5375
5545
|
return;
|
|
5376
5546
|
}
|
|
5377
|
-
if (
|
|
5547
|
+
if (!spatialFilter) {
|
|
5378
5548
|
addAllFeaturesInTile({
|
|
5379
5549
|
map,
|
|
5380
5550
|
data,
|
|
@@ -5388,7 +5558,7 @@ function calculateFeatures({
|
|
|
5388
5558
|
addIntersectedFeaturesInTile({
|
|
5389
5559
|
map,
|
|
5390
5560
|
data,
|
|
5391
|
-
|
|
5561
|
+
spatialFilter,
|
|
5392
5562
|
type,
|
|
5393
5563
|
bbox: bbox2,
|
|
5394
5564
|
tileFormat,
|
|
@@ -5439,129 +5609,8 @@ function createIndicesForPoints(data) {
|
|
|
5439
5609
|
|
|
5440
5610
|
// src/filters/tileFeaturesSpatialIndex.ts
|
|
5441
5611
|
init_cjs_shims();
|
|
5442
|
-
var
|
|
5443
|
-
|
|
5444
|
-
// node_modules/@turf/bbox-clip/dist/esm/index.js
|
|
5445
|
-
init_cjs_shims();
|
|
5446
|
-
function lineclip(points, bbox2, result) {
|
|
5447
|
-
var len = points.length, codeA = bitCode(points[0], bbox2), part = [], i, codeB, lastCode;
|
|
5448
|
-
let a;
|
|
5449
|
-
let b;
|
|
5450
|
-
if (!result) result = [];
|
|
5451
|
-
for (i = 1; i < len; i++) {
|
|
5452
|
-
a = points[i - 1];
|
|
5453
|
-
b = points[i];
|
|
5454
|
-
codeB = lastCode = bitCode(b, bbox2);
|
|
5455
|
-
while (true) {
|
|
5456
|
-
if (!(codeA | codeB)) {
|
|
5457
|
-
part.push(a);
|
|
5458
|
-
if (codeB !== lastCode) {
|
|
5459
|
-
part.push(b);
|
|
5460
|
-
if (i < len - 1) {
|
|
5461
|
-
result.push(part);
|
|
5462
|
-
part = [];
|
|
5463
|
-
}
|
|
5464
|
-
} else if (i === len - 1) {
|
|
5465
|
-
part.push(b);
|
|
5466
|
-
}
|
|
5467
|
-
break;
|
|
5468
|
-
} else if (codeA & codeB) {
|
|
5469
|
-
break;
|
|
5470
|
-
} else if (codeA) {
|
|
5471
|
-
a = intersect2(a, b, codeA, bbox2);
|
|
5472
|
-
codeA = bitCode(a, bbox2);
|
|
5473
|
-
} else {
|
|
5474
|
-
b = intersect2(a, b, codeB, bbox2);
|
|
5475
|
-
codeB = bitCode(b, bbox2);
|
|
5476
|
-
}
|
|
5477
|
-
}
|
|
5478
|
-
codeA = lastCode;
|
|
5479
|
-
}
|
|
5480
|
-
if (part.length) result.push(part);
|
|
5481
|
-
return result;
|
|
5482
|
-
}
|
|
5483
|
-
function polygonclip(points, bbox2) {
|
|
5484
|
-
var result, edge, prev, prevInside, i, p, inside;
|
|
5485
|
-
for (edge = 1; edge <= 8; edge *= 2) {
|
|
5486
|
-
result = [];
|
|
5487
|
-
prev = points[points.length - 1];
|
|
5488
|
-
prevInside = !(bitCode(prev, bbox2) & edge);
|
|
5489
|
-
for (i = 0; i < points.length; i++) {
|
|
5490
|
-
p = points[i];
|
|
5491
|
-
inside = !(bitCode(p, bbox2) & edge);
|
|
5492
|
-
if (inside !== prevInside) result.push(intersect2(prev, p, edge, bbox2));
|
|
5493
|
-
if (inside) result.push(p);
|
|
5494
|
-
prev = p;
|
|
5495
|
-
prevInside = inside;
|
|
5496
|
-
}
|
|
5497
|
-
points = result;
|
|
5498
|
-
if (!points.length) break;
|
|
5499
|
-
}
|
|
5500
|
-
return result;
|
|
5501
|
-
}
|
|
5502
|
-
function intersect2(a, b, edge, bbox2) {
|
|
5503
|
-
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;
|
|
5504
|
-
}
|
|
5505
|
-
function bitCode(p, bbox2) {
|
|
5506
|
-
var code = 0;
|
|
5507
|
-
if (p[0] < bbox2[0]) code |= 1;
|
|
5508
|
-
else if (p[0] > bbox2[2]) code |= 2;
|
|
5509
|
-
if (p[1] < bbox2[1]) code |= 4;
|
|
5510
|
-
else if (p[1] > bbox2[3]) code |= 8;
|
|
5511
|
-
return code;
|
|
5512
|
-
}
|
|
5513
|
-
function bboxClip(feature2, bbox2) {
|
|
5514
|
-
const geom = getGeom(feature2);
|
|
5515
|
-
const type = geom.type;
|
|
5516
|
-
const properties = feature2.type === "Feature" ? feature2.properties : {};
|
|
5517
|
-
let coords = geom.coordinates;
|
|
5518
|
-
switch (type) {
|
|
5519
|
-
case "LineString":
|
|
5520
|
-
case "MultiLineString": {
|
|
5521
|
-
const lines = [];
|
|
5522
|
-
if (type === "LineString") {
|
|
5523
|
-
coords = [coords];
|
|
5524
|
-
}
|
|
5525
|
-
coords.forEach((line) => {
|
|
5526
|
-
lineclip(line, bbox2, lines);
|
|
5527
|
-
});
|
|
5528
|
-
if (lines.length === 1) {
|
|
5529
|
-
return lineString(lines[0], properties);
|
|
5530
|
-
}
|
|
5531
|
-
return multiLineString(lines, properties);
|
|
5532
|
-
}
|
|
5533
|
-
case "Polygon":
|
|
5534
|
-
return polygon(clipPolygon(coords, bbox2), properties);
|
|
5535
|
-
case "MultiPolygon":
|
|
5536
|
-
return multiPolygon(
|
|
5537
|
-
coords.map((poly) => {
|
|
5538
|
-
return clipPolygon(poly, bbox2);
|
|
5539
|
-
}),
|
|
5540
|
-
properties
|
|
5541
|
-
);
|
|
5542
|
-
default:
|
|
5543
|
-
throw new Error("geometry " + type + " not supported");
|
|
5544
|
-
}
|
|
5545
|
-
}
|
|
5546
|
-
function clipPolygon(rings, bbox2) {
|
|
5547
|
-
const outRings = [];
|
|
5548
|
-
for (const ring of rings) {
|
|
5549
|
-
const clipped = polygonclip(ring, bbox2);
|
|
5550
|
-
if (clipped.length > 0) {
|
|
5551
|
-
if (clipped[0][0] !== clipped[clipped.length - 1][0] || clipped[0][1] !== clipped[clipped.length - 1][1]) {
|
|
5552
|
-
clipped.push(clipped[0]);
|
|
5553
|
-
}
|
|
5554
|
-
if (clipped.length >= 4) {
|
|
5555
|
-
outRings.push(clipped);
|
|
5556
|
-
}
|
|
5557
|
-
}
|
|
5558
|
-
}
|
|
5559
|
-
return outRings;
|
|
5560
|
-
}
|
|
5561
|
-
var turf_bbox_clip_default = bboxClip;
|
|
5562
|
-
|
|
5563
|
-
// src/filters/tileFeaturesSpatialIndex.ts
|
|
5564
|
-
var import_h3_js = require("h3-js");
|
|
5612
|
+
var import_quadbin2 = require("quadbin");
|
|
5613
|
+
var import_h3_js2 = require("h3-js");
|
|
5565
5614
|
function tileFeaturesSpatialIndex({
|
|
5566
5615
|
tiles,
|
|
5567
5616
|
spatialFilter,
|
|
@@ -5570,58 +5619,52 @@ function tileFeaturesSpatialIndex({
|
|
|
5570
5619
|
}) {
|
|
5571
5620
|
const map = /* @__PURE__ */ new Map();
|
|
5572
5621
|
const spatialIndex = getSpatialIndex(spatialDataType);
|
|
5573
|
-
const
|
|
5622
|
+
const cellResolution = getResolution(tiles, spatialIndex);
|
|
5574
5623
|
const spatialIndexIDName = spatialDataColumn ? spatialDataColumn : spatialIndex;
|
|
5575
|
-
if (!
|
|
5624
|
+
if (!cellResolution) {
|
|
5576
5625
|
return [];
|
|
5577
5626
|
}
|
|
5578
|
-
|
|
5579
|
-
if (
|
|
5580
|
-
|
|
5627
|
+
let intersection3;
|
|
5628
|
+
if (spatialIndex === "h3" /* H3 */) {
|
|
5629
|
+
intersection3 = intersectTileH3(cellResolution, spatialFilter);
|
|
5581
5630
|
}
|
|
5582
|
-
const cellsSet = new Set(cells);
|
|
5583
5631
|
for (const tile of tiles) {
|
|
5584
5632
|
if (tile.isVisible === false || !tile.data) {
|
|
5585
5633
|
continue;
|
|
5586
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;
|
|
5587
5644
|
tile.data.forEach((d) => {
|
|
5588
|
-
if (
|
|
5645
|
+
if (intersection3 === true || intersection3.has(d.id)) {
|
|
5589
5646
|
map.set(d.id, { ...d.properties, [spatialIndexIDName]: d.id });
|
|
5590
5647
|
}
|
|
5591
5648
|
});
|
|
5592
5649
|
}
|
|
5593
5650
|
return Array.from(map.values());
|
|
5594
5651
|
}
|
|
5652
|
+
function getTileIndex(tile, spatialIndex) {
|
|
5653
|
+
if (spatialIndex === "quadbin" /* QUADBIN */) {
|
|
5654
|
+
return tile.index.q;
|
|
5655
|
+
}
|
|
5656
|
+
return tile.id;
|
|
5657
|
+
}
|
|
5595
5658
|
function getResolution(tiles, spatialIndex) {
|
|
5596
5659
|
const data = tiles.find((tile) => tile.data?.length)?.data;
|
|
5597
5660
|
if (!data) {
|
|
5598
5661
|
return;
|
|
5599
5662
|
}
|
|
5600
5663
|
if (spatialIndex === "quadbin" /* QUADBIN */) {
|
|
5601
|
-
return Number((0,
|
|
5602
|
-
}
|
|
5603
|
-
if (spatialIndex === "h3" /* H3 */) {
|
|
5604
|
-
return (0, import_h3_js.getResolution)(data[0].id);
|
|
5605
|
-
}
|
|
5606
|
-
}
|
|
5607
|
-
var bboxWest = [-180, -90, 0, 90];
|
|
5608
|
-
var bboxEast = [0, -90, 180, 90];
|
|
5609
|
-
function getCellsCoverGeometry(geometry, spatialIndex, resolution) {
|
|
5610
|
-
if (spatialIndex === "quadbin" /* QUADBIN */) {
|
|
5611
|
-
return (0, import_quadbin.geometryToCells)(geometry, resolution);
|
|
5664
|
+
return Number((0, import_quadbin2.getResolution)(data[0].id));
|
|
5612
5665
|
}
|
|
5613
5666
|
if (spatialIndex === "h3" /* H3 */) {
|
|
5614
|
-
return (0,
|
|
5615
|
-
turf_bbox_clip_default(geometry, bboxWest).geometry.coordinates,
|
|
5616
|
-
resolution,
|
|
5617
|
-
true
|
|
5618
|
-
).concat(
|
|
5619
|
-
(0, import_h3_js.polygonToCells)(
|
|
5620
|
-
turf_bbox_clip_default(geometry, bboxEast).geometry.coordinates,
|
|
5621
|
-
resolution,
|
|
5622
|
-
true
|
|
5623
|
-
)
|
|
5624
|
-
);
|
|
5667
|
+
return (0, import_h3_js2.getResolution)(data[0].id);
|
|
5625
5668
|
}
|
|
5626
5669
|
}
|
|
5627
5670
|
function getSpatialIndex(spatialDataType) {
|
|
@@ -5649,7 +5692,7 @@ var DEFAULT_AGGREGATION_EXP = `1 AS ${DEFAULT_AGGREGATION_EXP_ALIAS}`;
|
|
|
5649
5692
|
|
|
5650
5693
|
// src/filters/tileFeaturesRaster.ts
|
|
5651
5694
|
init_cjs_shims();
|
|
5652
|
-
var
|
|
5695
|
+
var import_quadbin3 = require("quadbin");
|
|
5653
5696
|
function tileFeaturesRaster({
|
|
5654
5697
|
tiles,
|
|
5655
5698
|
...options
|
|
@@ -5660,18 +5703,23 @@ function tileFeaturesRaster({
|
|
|
5660
5703
|
}
|
|
5661
5704
|
tiles = tiles.filter(isRasterTileVisible);
|
|
5662
5705
|
if (tiles.length === 0) return [];
|
|
5663
|
-
const tileResolution = (0,
|
|
5706
|
+
const tileResolution = (0, import_quadbin3.getResolution)(tiles[0].index.q);
|
|
5664
5707
|
const tileBlockSize = tiles[0].data.blockSize;
|
|
5665
5708
|
const cellResolution = tileResolution + BigInt(Math.log2(tileBlockSize));
|
|
5666
|
-
const spatialFilterCells = new Set(
|
|
5667
|
-
(0, import_quadbin2.geometryToCells)(options.spatialFilter, cellResolution)
|
|
5668
|
-
);
|
|
5669
5709
|
const data = /* @__PURE__ */ new Map();
|
|
5670
5710
|
for (const tile of tiles) {
|
|
5671
5711
|
const parent = tile.index.q;
|
|
5672
|
-
const
|
|
5673
|
-
|
|
5674
|
-
|
|
5712
|
+
const intersection3 = intersectTileRaster(
|
|
5713
|
+
parent,
|
|
5714
|
+
cellResolution,
|
|
5715
|
+
options.spatialFilter
|
|
5716
|
+
);
|
|
5717
|
+
if (intersection3 === false) continue;
|
|
5718
|
+
const tileSortedCells = cellToChildrenSorted(parent, cellResolution);
|
|
5719
|
+
for (let i = 0; i < tileSortedCells.length; i++) {
|
|
5720
|
+
if (intersection3 !== true && !intersection3.has(tileSortedCells[i])) {
|
|
5721
|
+
continue;
|
|
5722
|
+
}
|
|
5675
5723
|
const cellData = {};
|
|
5676
5724
|
let cellDataExists = false;
|
|
5677
5725
|
for (const band in tile.data.cells.numericProps) {
|
|
@@ -5683,7 +5731,7 @@ function tileFeaturesRaster({
|
|
|
5683
5731
|
}
|
|
5684
5732
|
}
|
|
5685
5733
|
if (cellDataExists) {
|
|
5686
|
-
data.set(
|
|
5734
|
+
data.set(tileSortedCells[i], cellData);
|
|
5687
5735
|
}
|
|
5688
5736
|
}
|
|
5689
5737
|
}
|
|
@@ -5696,10 +5744,10 @@ function isRasterTileVisible(tile) {
|
|
|
5696
5744
|
return !!(tile.isVisible && tile.data?.cells?.numericProps);
|
|
5697
5745
|
}
|
|
5698
5746
|
function cellToChildrenSorted(parent, resolution) {
|
|
5699
|
-
return (0,
|
|
5747
|
+
return (0, import_quadbin3.cellToChildren)(parent, resolution).sort(
|
|
5700
5748
|
(cellA, cellB) => {
|
|
5701
|
-
const tileA = (0,
|
|
5702
|
-
const tileB = (0,
|
|
5749
|
+
const tileA = (0, import_quadbin3.cellToTile)(cellA);
|
|
5750
|
+
const tileB = (0, import_quadbin3.cellToTile)(cellB);
|
|
5703
5751
|
if (tileA.y !== tileB.y) {
|
|
5704
5752
|
return tileA.y > tileB.y ? 1 : -1;
|
|
5705
5753
|
}
|
|
@@ -7460,7 +7508,7 @@ var WidgetTilesetSourceImpl = class extends WidgetSource {
|
|
|
7460
7508
|
}
|
|
7461
7509
|
_extractTileFeatures(spatialFilter) {
|
|
7462
7510
|
const prevInputs = this._tileFeatureExtractPreviousInputs;
|
|
7463
|
-
if (this._features.length &&
|
|
7511
|
+
if (this._features.length && spatialFilterEquals(prevInputs.spatialFilter, spatialFilter)) {
|
|
7464
7512
|
return;
|
|
7465
7513
|
}
|
|
7466
7514
|
this._features = tileFeatures({
|
|
@@ -7700,7 +7748,6 @@ var WidgetTilesetSourceImpl = class extends WidgetSource {
|
|
|
7700
7748
|
* INTERNAL
|
|
7701
7749
|
*/
|
|
7702
7750
|
_getFilteredFeatures(spatialFilter, filters, filterOwner) {
|
|
7703
|
-
assert2(spatialFilter, "spatialFilter required for tilesets");
|
|
7704
7751
|
this._extractTileFeatures(spatialFilter);
|
|
7705
7752
|
return applyFilters(
|
|
7706
7753
|
this._features,
|
|
@@ -7724,6 +7771,11 @@ function assertColumn(features, ...columnArgs) {
|
|
|
7724
7771
|
function normalizeColumns(columns) {
|
|
7725
7772
|
return Array.isArray(columns) ? columns : typeof columns === "string" ? [columns] : [];
|
|
7726
7773
|
}
|
|
7774
|
+
function spatialFilterEquals(a, b) {
|
|
7775
|
+
if (a === b) return true;
|
|
7776
|
+
if (!a || !b) return false;
|
|
7777
|
+
return booleanEqual(a, b);
|
|
7778
|
+
}
|
|
7727
7779
|
|
|
7728
7780
|
// src/widget-sources/widget-tileset-source.ts
|
|
7729
7781
|
var WidgetTilesetSource = class extends WidgetSource {
|
|
@@ -10288,12 +10340,70 @@ function _getHexagonResolution(viewport, tileSize) {
|
|
|
10288
10340
|
Math.floor(hexagonScaleFactor + latitudeScaleFactor - BIAS)
|
|
10289
10341
|
);
|
|
10290
10342
|
}
|
|
10343
|
+
|
|
10344
|
+
// src/utils/CellSet.ts
|
|
10345
|
+
init_cjs_shims();
|
|
10346
|
+
var EMPTY_U32 = 2 ** 32 - 1;
|
|
10347
|
+
var CellSet = class {
|
|
10348
|
+
constructor(cells) {
|
|
10349
|
+
/** List of cells stored by the set. Stored by reference, without copying. */
|
|
10350
|
+
__publicField(this, "cells");
|
|
10351
|
+
/** DataView representing a single cell ID. Pre-allocated to reduce memory during queries. */
|
|
10352
|
+
__publicField(this, "cellView", new DataView(new ArrayBuffer(8)));
|
|
10353
|
+
/** Hash table, mapping a hash index (computed) to an index in the 'cells' array. */
|
|
10354
|
+
__publicField(this, "hashTable");
|
|
10355
|
+
this.cells = cells;
|
|
10356
|
+
this.hashTable = new Uint32Array(hashBuckets(cells.length)).fill(EMPTY_U32);
|
|
10357
|
+
for (let cellIndex = 0; cellIndex < cells.length; cellIndex++) {
|
|
10358
|
+
this.hashTable[this.hashLookup(cells[cellIndex])] = cellIndex;
|
|
10359
|
+
}
|
|
10360
|
+
}
|
|
10361
|
+
has(cell) {
|
|
10362
|
+
const hashIndex = this.hashLookup(cell);
|
|
10363
|
+
return this.hashTable[hashIndex] !== EMPTY_U32;
|
|
10364
|
+
}
|
|
10365
|
+
hashLookup(cell) {
|
|
10366
|
+
this.cellView.setBigUint64(0, cell);
|
|
10367
|
+
const hashval = hash(this.cellView);
|
|
10368
|
+
const hashmod = this.hashTable.length - 1;
|
|
10369
|
+
let bucket = hashval & hashmod;
|
|
10370
|
+
for (let probe = 0; probe <= hashmod; probe++) {
|
|
10371
|
+
const cellIndex = this.hashTable[bucket];
|
|
10372
|
+
if (cellIndex === EMPTY_U32 || cell === this.cells[cellIndex]) {
|
|
10373
|
+
return bucket;
|
|
10374
|
+
}
|
|
10375
|
+
bucket = bucket + probe + 1 & hashmod;
|
|
10376
|
+
}
|
|
10377
|
+
throw new Error("Hash table full.");
|
|
10378
|
+
}
|
|
10379
|
+
};
|
|
10380
|
+
function hash(view, h = 0) {
|
|
10381
|
+
const m = 1540483477;
|
|
10382
|
+
const r = 24;
|
|
10383
|
+
for (let i = 0, il = view.byteLength / 4; i < il; i++) {
|
|
10384
|
+
let k = view.getUint32(i * 4);
|
|
10385
|
+
k = Math.imul(k, m) >>> 0;
|
|
10386
|
+
k = (k ^ k >> r) >>> 0;
|
|
10387
|
+
k = Math.imul(k, m) >>> 0;
|
|
10388
|
+
h = Math.imul(h, m) >>> 0;
|
|
10389
|
+
h = (h ^ k) >>> 0;
|
|
10390
|
+
}
|
|
10391
|
+
return h;
|
|
10392
|
+
}
|
|
10393
|
+
function hashBuckets(initialCount) {
|
|
10394
|
+
let buckets = 1;
|
|
10395
|
+
while (buckets < initialCount + initialCount / 4) {
|
|
10396
|
+
buckets *= 2;
|
|
10397
|
+
}
|
|
10398
|
+
return buckets;
|
|
10399
|
+
}
|
|
10291
10400
|
// Annotate the CommonJS export names for ESM import in node:
|
|
10292
10401
|
0 && (module.exports = {
|
|
10293
10402
|
AggregationTypes,
|
|
10294
10403
|
ApiVersion,
|
|
10295
10404
|
BASEMAP,
|
|
10296
10405
|
CartoAPIError,
|
|
10406
|
+
CellSet,
|
|
10297
10407
|
DEFAULT_API_BASE_URL,
|
|
10298
10408
|
FEATURE_GEOM_PROPERTY,
|
|
10299
10409
|
FilterType,
|