@carto/api-client 0.5.6 → 0.5.7-alpha-optional-spatial-filter.0
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 +462 -345
- 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 +426 -309
- package/build/api-client.js.map +1 -1
- package/build/worker-compat.js +4214 -2963
- package/build/worker-compat.js.map +1 -1
- package/build/worker.js +395 -335
- 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 -52
- package/src/filters/tileIntersection.ts +158 -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,190 @@ 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;
|
|
5117
5191
|
}
|
|
5118
|
-
|
|
5119
|
-
|
|
5120
|
-
|
|
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;
|
|
5211
|
+
}
|
|
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(parent, cellResolution, spatialFilter) {
|
|
5312
|
+
const tilePolygon = {
|
|
5313
|
+
type: "Polygon",
|
|
5314
|
+
coordinates: [(0, import_h3_js.cellToBoundary)(parent, true)]
|
|
5315
|
+
};
|
|
5316
|
+
if (!spatialFilter || turf_boolean_within_default(tilePolygon, spatialFilter)) {
|
|
5317
|
+
return true;
|
|
5318
|
+
}
|
|
5319
|
+
const clippedSpatialFilter = turf_intersect_default(
|
|
5320
|
+
featureCollection([feature(tilePolygon), feature(spatialFilter)])
|
|
5321
|
+
);
|
|
5322
|
+
if (!clippedSpatialFilter) {
|
|
5323
|
+
return false;
|
|
5324
|
+
}
|
|
5325
|
+
const cellsWest = (0, import_h3_js.polygonToCells)(
|
|
5326
|
+
turf_bbox_clip_default(clippedSpatialFilter, BBOX_WEST).geometry.coordinates,
|
|
5327
|
+
cellResolution,
|
|
5328
|
+
true
|
|
5329
|
+
);
|
|
5330
|
+
const cellsEast = (0, import_h3_js.polygonToCells)(
|
|
5331
|
+
turf_bbox_clip_default(clippedSpatialFilter, BBOX_EAST).geometry.coordinates,
|
|
5332
|
+
cellResolution,
|
|
5333
|
+
true
|
|
5334
|
+
);
|
|
5335
|
+
return new Set(cellsWest.concat(cellsEast));
|
|
5146
5336
|
}
|
|
5147
5337
|
|
|
5148
5338
|
// src/filters/tileFeaturesGeometries.ts
|
|
@@ -5159,55 +5349,45 @@ function tileFeaturesGeometries({
|
|
|
5159
5349
|
if (tile.isVisible === false || !tile.data) {
|
|
5160
5350
|
continue;
|
|
5161
5351
|
}
|
|
5162
|
-
const
|
|
5352
|
+
const tileBbox = [
|
|
5163
5353
|
tile.bbox.west,
|
|
5164
5354
|
tile.bbox.south,
|
|
5165
5355
|
tile.bbox.east,
|
|
5166
5356
|
tile.bbox.north
|
|
5167
5357
|
];
|
|
5168
|
-
const
|
|
5169
|
-
|
|
5170
|
-
|
|
5171
|
-
|
|
5172
|
-
geometry: spatialFilter,
|
|
5173
|
-
properties: {}
|
|
5174
|
-
};
|
|
5175
|
-
const clippedGeometryToIntersect = turf_intersect_default(
|
|
5176
|
-
featureCollection([bboxToGeom, spatialFilterFeature])
|
|
5358
|
+
const intersection3 = intersectTileGeometry(
|
|
5359
|
+
tileBbox,
|
|
5360
|
+
tileFormat,
|
|
5361
|
+
spatialFilter
|
|
5177
5362
|
);
|
|
5178
|
-
if (
|
|
5179
|
-
|
|
5180
|
-
}
|
|
5181
|
-
const transformedGeometryToIntersect = tileFormat === "mvt" /* MVT */ ? transformToTileCoords(clippedGeometryToIntersect.geometry, bbox2) : clippedGeometryToIntersect.geometry;
|
|
5363
|
+
if (intersection3 === false) continue;
|
|
5364
|
+
const transformedSpatialFilter = intersection3 === true ? void 0 : intersection3;
|
|
5182
5365
|
calculateFeatures({
|
|
5183
5366
|
map,
|
|
5184
|
-
|
|
5185
|
-
geometryIntersection: transformedGeometryToIntersect,
|
|
5367
|
+
spatialFilter: transformedSpatialFilter,
|
|
5186
5368
|
data: tile.data.points,
|
|
5187
5369
|
type: "Point",
|
|
5188
|
-
bbox:
|
|
5370
|
+
bbox: tileBbox,
|
|
5189
5371
|
tileFormat,
|
|
5190
5372
|
uniqueIdProperty,
|
|
5191
5373
|
options
|
|
5192
5374
|
});
|
|
5193
5375
|
calculateFeatures({
|
|
5194
5376
|
map,
|
|
5195
|
-
|
|
5196
|
-
geometryIntersection: transformedGeometryToIntersect,
|
|
5377
|
+
spatialFilter: transformedSpatialFilter,
|
|
5197
5378
|
data: tile.data.lines,
|
|
5198
5379
|
type: "LineString",
|
|
5199
|
-
bbox:
|
|
5380
|
+
bbox: tileBbox,
|
|
5200
5381
|
tileFormat,
|
|
5201
5382
|
uniqueIdProperty,
|
|
5202
5383
|
options
|
|
5203
5384
|
});
|
|
5204
5385
|
calculateFeatures({
|
|
5205
5386
|
map,
|
|
5206
|
-
|
|
5207
|
-
geometryIntersection: transformedGeometryToIntersect,
|
|
5387
|
+
spatialFilter: transformedSpatialFilter,
|
|
5208
5388
|
data: tile.data.polygons,
|
|
5209
5389
|
type: "Polygon",
|
|
5210
|
-
bbox:
|
|
5390
|
+
bbox: tileBbox,
|
|
5211
5391
|
tileFormat,
|
|
5212
5392
|
uniqueIdProperty,
|
|
5213
5393
|
options
|
|
@@ -5225,7 +5405,7 @@ function processTileFeatureProperties({
|
|
|
5225
5405
|
tileFormat,
|
|
5226
5406
|
uniqueIdProperty,
|
|
5227
5407
|
storeGeometry,
|
|
5228
|
-
|
|
5408
|
+
spatialFilter
|
|
5229
5409
|
}) {
|
|
5230
5410
|
const tileProps = getPropertiesFromTile(data, startIndex);
|
|
5231
5411
|
const uniquePropertyValue = getUniquePropertyValue(
|
|
@@ -5237,7 +5417,7 @@ function processTileFeatureProperties({
|
|
|
5237
5417
|
return;
|
|
5238
5418
|
}
|
|
5239
5419
|
let geometry = null;
|
|
5240
|
-
if (storeGeometry ||
|
|
5420
|
+
if (storeGeometry || spatialFilter) {
|
|
5241
5421
|
const { positions } = data;
|
|
5242
5422
|
const ringCoordinates = getRingCoordinatesFor(
|
|
5243
5423
|
startIndex,
|
|
@@ -5246,7 +5426,7 @@ function processTileFeatureProperties({
|
|
|
5246
5426
|
);
|
|
5247
5427
|
geometry = getFeatureByType(ringCoordinates, type);
|
|
5248
5428
|
}
|
|
5249
|
-
if (geometry &&
|
|
5429
|
+
if (geometry && spatialFilter && !turf_boolean_intersects_default(geometry, spatialFilter)) {
|
|
5250
5430
|
return;
|
|
5251
5431
|
}
|
|
5252
5432
|
const properties = parseProperties(tileProps);
|
|
@@ -5258,7 +5438,7 @@ function processTileFeatureProperties({
|
|
|
5258
5438
|
function addIntersectedFeaturesInTile({
|
|
5259
5439
|
map,
|
|
5260
5440
|
data,
|
|
5261
|
-
|
|
5441
|
+
spatialFilter,
|
|
5262
5442
|
type,
|
|
5263
5443
|
bbox: bbox2,
|
|
5264
5444
|
tileFormat,
|
|
@@ -5280,7 +5460,7 @@ function addIntersectedFeaturesInTile({
|
|
|
5280
5460
|
tileFormat,
|
|
5281
5461
|
uniqueIdProperty,
|
|
5282
5462
|
storeGeometry,
|
|
5283
|
-
|
|
5463
|
+
spatialFilter
|
|
5284
5464
|
});
|
|
5285
5465
|
}
|
|
5286
5466
|
}
|
|
@@ -5362,8 +5542,7 @@ function getRingCoordinatesFor(startIndex, endIndex, positions) {
|
|
|
5362
5542
|
}
|
|
5363
5543
|
function calculateFeatures({
|
|
5364
5544
|
map,
|
|
5365
|
-
|
|
5366
|
-
geometryIntersection,
|
|
5545
|
+
spatialFilter,
|
|
5367
5546
|
data,
|
|
5368
5547
|
type,
|
|
5369
5548
|
bbox: bbox2,
|
|
@@ -5374,7 +5553,7 @@ function calculateFeatures({
|
|
|
5374
5553
|
if (!data?.properties.length) {
|
|
5375
5554
|
return;
|
|
5376
5555
|
}
|
|
5377
|
-
if (
|
|
5556
|
+
if (!spatialFilter) {
|
|
5378
5557
|
addAllFeaturesInTile({
|
|
5379
5558
|
map,
|
|
5380
5559
|
data,
|
|
@@ -5388,7 +5567,7 @@ function calculateFeatures({
|
|
|
5388
5567
|
addIntersectedFeaturesInTile({
|
|
5389
5568
|
map,
|
|
5390
5569
|
data,
|
|
5391
|
-
|
|
5570
|
+
spatialFilter,
|
|
5392
5571
|
type,
|
|
5393
5572
|
bbox: bbox2,
|
|
5394
5573
|
tileFormat,
|
|
@@ -5439,129 +5618,8 @@ function createIndicesForPoints(data) {
|
|
|
5439
5618
|
|
|
5440
5619
|
// src/filters/tileFeaturesSpatialIndex.ts
|
|
5441
5620
|
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");
|
|
5621
|
+
var import_quadbin2 = require("quadbin");
|
|
5622
|
+
var import_h3_js2 = require("h3-js");
|
|
5565
5623
|
function tileFeaturesSpatialIndex({
|
|
5566
5624
|
tiles,
|
|
5567
5625
|
spatialFilter,
|
|
@@ -5570,58 +5628,50 @@ function tileFeaturesSpatialIndex({
|
|
|
5570
5628
|
}) {
|
|
5571
5629
|
const map = /* @__PURE__ */ new Map();
|
|
5572
5630
|
const spatialIndex = getSpatialIndex(spatialDataType);
|
|
5573
|
-
const
|
|
5631
|
+
const cellResolution = getResolution(tiles, spatialIndex);
|
|
5574
5632
|
const spatialIndexIDName = spatialDataColumn ? spatialDataColumn : spatialIndex;
|
|
5575
|
-
if (!
|
|
5576
|
-
return [];
|
|
5577
|
-
}
|
|
5578
|
-
const cells = getCellsCoverGeometry(spatialFilter, spatialIndex, resolution);
|
|
5579
|
-
if (!cells?.length) {
|
|
5633
|
+
if (!cellResolution) {
|
|
5580
5634
|
return [];
|
|
5581
5635
|
}
|
|
5582
|
-
const cellsSet = new Set(cells);
|
|
5583
5636
|
for (const tile of tiles) {
|
|
5584
5637
|
if (tile.isVisible === false || !tile.data) {
|
|
5585
5638
|
continue;
|
|
5586
5639
|
}
|
|
5640
|
+
const parent = getTileIndex(tile, spatialIndex);
|
|
5641
|
+
const intersection3 = spatialIndex === "quadbin" /* QUADBIN */ ? intersectTileQuadbin(
|
|
5642
|
+
parent,
|
|
5643
|
+
cellResolution,
|
|
5644
|
+
spatialFilter
|
|
5645
|
+
) : intersectTileH3(
|
|
5646
|
+
parent,
|
|
5647
|
+
cellResolution,
|
|
5648
|
+
spatialFilter
|
|
5649
|
+
);
|
|
5650
|
+
if (!intersection3) continue;
|
|
5587
5651
|
tile.data.forEach((d) => {
|
|
5588
|
-
if (
|
|
5652
|
+
if (intersection3 === true || intersection3.has(d.id)) {
|
|
5589
5653
|
map.set(d.id, { ...d.properties, [spatialIndexIDName]: d.id });
|
|
5590
5654
|
}
|
|
5591
5655
|
});
|
|
5592
5656
|
}
|
|
5593
5657
|
return Array.from(map.values());
|
|
5594
5658
|
}
|
|
5659
|
+
function getTileIndex(tile, spatialIndex) {
|
|
5660
|
+
if (spatialIndex === "quadbin" /* QUADBIN */) {
|
|
5661
|
+
return tile.index.q;
|
|
5662
|
+
}
|
|
5663
|
+
return tile.id;
|
|
5664
|
+
}
|
|
5595
5665
|
function getResolution(tiles, spatialIndex) {
|
|
5596
5666
|
const data = tiles.find((tile) => tile.data?.length)?.data;
|
|
5597
5667
|
if (!data) {
|
|
5598
5668
|
return;
|
|
5599
5669
|
}
|
|
5600
5670
|
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);
|
|
5671
|
+
return Number((0, import_quadbin2.getResolution)(data[0].id));
|
|
5612
5672
|
}
|
|
5613
5673
|
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
|
-
);
|
|
5674
|
+
return (0, import_h3_js2.getResolution)(data[0].id);
|
|
5625
5675
|
}
|
|
5626
5676
|
}
|
|
5627
5677
|
function getSpatialIndex(spatialDataType) {
|
|
@@ -5649,7 +5699,7 @@ var DEFAULT_AGGREGATION_EXP = `1 AS ${DEFAULT_AGGREGATION_EXP_ALIAS}`;
|
|
|
5649
5699
|
|
|
5650
5700
|
// src/filters/tileFeaturesRaster.ts
|
|
5651
5701
|
init_cjs_shims();
|
|
5652
|
-
var
|
|
5702
|
+
var import_quadbin3 = require("quadbin");
|
|
5653
5703
|
function tileFeaturesRaster({
|
|
5654
5704
|
tiles,
|
|
5655
5705
|
...options
|
|
@@ -5660,18 +5710,23 @@ function tileFeaturesRaster({
|
|
|
5660
5710
|
}
|
|
5661
5711
|
tiles = tiles.filter(isRasterTileVisible);
|
|
5662
5712
|
if (tiles.length === 0) return [];
|
|
5663
|
-
const tileResolution = (0,
|
|
5713
|
+
const tileResolution = (0, import_quadbin3.getResolution)(tiles[0].index.q);
|
|
5664
5714
|
const tileBlockSize = tiles[0].data.blockSize;
|
|
5665
5715
|
const cellResolution = tileResolution + BigInt(Math.log2(tileBlockSize));
|
|
5666
|
-
const spatialFilterCells = new Set(
|
|
5667
|
-
(0, import_quadbin2.geometryToCells)(options.spatialFilter, cellResolution)
|
|
5668
|
-
);
|
|
5669
5716
|
const data = /* @__PURE__ */ new Map();
|
|
5670
5717
|
for (const tile of tiles) {
|
|
5671
5718
|
const parent = tile.index.q;
|
|
5672
|
-
const
|
|
5673
|
-
|
|
5674
|
-
|
|
5719
|
+
const intersection3 = intersectTileRaster(
|
|
5720
|
+
parent,
|
|
5721
|
+
cellResolution,
|
|
5722
|
+
options.spatialFilter
|
|
5723
|
+
);
|
|
5724
|
+
if (intersection3 === false) continue;
|
|
5725
|
+
const tileSortedCells = cellToChildrenSorted(parent, cellResolution);
|
|
5726
|
+
for (let i = 0; i < tileSortedCells.length; i++) {
|
|
5727
|
+
if (intersection3 !== true && !intersection3.has(tileSortedCells[i])) {
|
|
5728
|
+
continue;
|
|
5729
|
+
}
|
|
5675
5730
|
const cellData = {};
|
|
5676
5731
|
let cellDataExists = false;
|
|
5677
5732
|
for (const band in tile.data.cells.numericProps) {
|
|
@@ -5683,7 +5738,7 @@ function tileFeaturesRaster({
|
|
|
5683
5738
|
}
|
|
5684
5739
|
}
|
|
5685
5740
|
if (cellDataExists) {
|
|
5686
|
-
data.set(
|
|
5741
|
+
data.set(tileSortedCells[i], cellData);
|
|
5687
5742
|
}
|
|
5688
5743
|
}
|
|
5689
5744
|
}
|
|
@@ -5696,10 +5751,10 @@ function isRasterTileVisible(tile) {
|
|
|
5696
5751
|
return !!(tile.isVisible && tile.data?.cells?.numericProps);
|
|
5697
5752
|
}
|
|
5698
5753
|
function cellToChildrenSorted(parent, resolution) {
|
|
5699
|
-
return (0,
|
|
5754
|
+
return (0, import_quadbin3.cellToChildren)(parent, resolution).sort(
|
|
5700
5755
|
(cellA, cellB) => {
|
|
5701
|
-
const tileA = (0,
|
|
5702
|
-
const tileB = (0,
|
|
5756
|
+
const tileA = (0, import_quadbin3.cellToTile)(cellA);
|
|
5757
|
+
const tileB = (0, import_quadbin3.cellToTile)(cellB);
|
|
5703
5758
|
if (tileA.y !== tileB.y) {
|
|
5704
5759
|
return tileA.y > tileB.y ? 1 : -1;
|
|
5705
5760
|
}
|
|
@@ -7460,7 +7515,7 @@ var WidgetTilesetSourceImpl = class extends WidgetSource {
|
|
|
7460
7515
|
}
|
|
7461
7516
|
_extractTileFeatures(spatialFilter) {
|
|
7462
7517
|
const prevInputs = this._tileFeatureExtractPreviousInputs;
|
|
7463
|
-
if (this._features.length &&
|
|
7518
|
+
if (this._features.length && spatialFilterEquals(prevInputs.spatialFilter, spatialFilter)) {
|
|
7464
7519
|
return;
|
|
7465
7520
|
}
|
|
7466
7521
|
this._features = tileFeatures({
|
|
@@ -7700,7 +7755,6 @@ var WidgetTilesetSourceImpl = class extends WidgetSource {
|
|
|
7700
7755
|
* INTERNAL
|
|
7701
7756
|
*/
|
|
7702
7757
|
_getFilteredFeatures(spatialFilter, filters, filterOwner) {
|
|
7703
|
-
assert2(spatialFilter, "spatialFilter required for tilesets");
|
|
7704
7758
|
this._extractTileFeatures(spatialFilter);
|
|
7705
7759
|
return applyFilters(
|
|
7706
7760
|
this._features,
|
|
@@ -7724,6 +7778,11 @@ function assertColumn(features, ...columnArgs) {
|
|
|
7724
7778
|
function normalizeColumns(columns) {
|
|
7725
7779
|
return Array.isArray(columns) ? columns : typeof columns === "string" ? [columns] : [];
|
|
7726
7780
|
}
|
|
7781
|
+
function spatialFilterEquals(a, b) {
|
|
7782
|
+
if (a === b) return true;
|
|
7783
|
+
if (!a || !b) return false;
|
|
7784
|
+
return booleanEqual(a, b);
|
|
7785
|
+
}
|
|
7727
7786
|
|
|
7728
7787
|
// src/widget-sources/widget-tileset-source.ts
|
|
7729
7788
|
var WidgetTilesetSource = class extends WidgetSource {
|
|
@@ -10288,12 +10347,70 @@ function _getHexagonResolution(viewport, tileSize) {
|
|
|
10288
10347
|
Math.floor(hexagonScaleFactor + latitudeScaleFactor - BIAS)
|
|
10289
10348
|
);
|
|
10290
10349
|
}
|
|
10350
|
+
|
|
10351
|
+
// src/utils/CellSet.ts
|
|
10352
|
+
init_cjs_shims();
|
|
10353
|
+
var EMPTY_U32 = 2 ** 32 - 1;
|
|
10354
|
+
var CellSet = class {
|
|
10355
|
+
constructor(cells) {
|
|
10356
|
+
/** List of cells stored by the set. Stored by reference, without copying. */
|
|
10357
|
+
__publicField(this, "cells");
|
|
10358
|
+
/** DataView representing a single cell ID. Pre-allocated to reduce memory during queries. */
|
|
10359
|
+
__publicField(this, "cellView", new DataView(new ArrayBuffer(8)));
|
|
10360
|
+
/** Hash table, mapping a hash index (computed) to an index in the 'cells' array. */
|
|
10361
|
+
__publicField(this, "hashTable");
|
|
10362
|
+
this.cells = cells;
|
|
10363
|
+
this.hashTable = new Uint32Array(hashBuckets(cells.length)).fill(EMPTY_U32);
|
|
10364
|
+
for (let cellIndex = 0; cellIndex < cells.length; cellIndex++) {
|
|
10365
|
+
this.hashTable[this.hashLookup(cells[cellIndex])] = cellIndex;
|
|
10366
|
+
}
|
|
10367
|
+
}
|
|
10368
|
+
has(cell) {
|
|
10369
|
+
const hashIndex = this.hashLookup(cell);
|
|
10370
|
+
return this.hashTable[hashIndex] !== EMPTY_U32;
|
|
10371
|
+
}
|
|
10372
|
+
hashLookup(cell) {
|
|
10373
|
+
this.cellView.setBigUint64(0, cell);
|
|
10374
|
+
const hashval = hash(this.cellView);
|
|
10375
|
+
const hashmod = this.hashTable.length - 1;
|
|
10376
|
+
let bucket = hashval & hashmod;
|
|
10377
|
+
for (let probe = 0; probe <= hashmod; probe++) {
|
|
10378
|
+
const cellIndex = this.hashTable[bucket];
|
|
10379
|
+
if (cellIndex === EMPTY_U32 || cell === this.cells[cellIndex]) {
|
|
10380
|
+
return bucket;
|
|
10381
|
+
}
|
|
10382
|
+
bucket = bucket + probe + 1 & hashmod;
|
|
10383
|
+
}
|
|
10384
|
+
throw new Error("Hash table full.");
|
|
10385
|
+
}
|
|
10386
|
+
};
|
|
10387
|
+
function hash(view, h = 0) {
|
|
10388
|
+
const m = 1540483477;
|
|
10389
|
+
const r = 24;
|
|
10390
|
+
for (let i = 0, il = view.byteLength / 4; i < il; i++) {
|
|
10391
|
+
let k = view.getUint32(i * 4);
|
|
10392
|
+
k = Math.imul(k, m) >>> 0;
|
|
10393
|
+
k = (k ^ k >> r) >>> 0;
|
|
10394
|
+
k = Math.imul(k, m) >>> 0;
|
|
10395
|
+
h = Math.imul(h, m) >>> 0;
|
|
10396
|
+
h = (h ^ k) >>> 0;
|
|
10397
|
+
}
|
|
10398
|
+
return h;
|
|
10399
|
+
}
|
|
10400
|
+
function hashBuckets(initialCount) {
|
|
10401
|
+
let buckets = 1;
|
|
10402
|
+
while (buckets < initialCount + initialCount / 4) {
|
|
10403
|
+
buckets *= 2;
|
|
10404
|
+
}
|
|
10405
|
+
return buckets;
|
|
10406
|
+
}
|
|
10291
10407
|
// Annotate the CommonJS export names for ESM import in node:
|
|
10292
10408
|
0 && (module.exports = {
|
|
10293
10409
|
AggregationTypes,
|
|
10294
10410
|
ApiVersion,
|
|
10295
10411
|
BASEMAP,
|
|
10296
10412
|
CartoAPIError,
|
|
10413
|
+
CellSet,
|
|
10297
10414
|
DEFAULT_API_BASE_URL,
|
|
10298
10415
|
FEATURE_GEOM_PROPERTY,
|
|
10299
10416
|
FilterType,
|