@carto/api-client 0.5.6-alpha.bundle.4 → 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/CHANGELOG.md +7 -0
- package/build/api-client.cjs +488 -361
- package/build/api-client.cjs.map +1 -1
- package/build/api-client.d.cts +35 -6
- package/build/api-client.d.ts +35 -6
- package/build/api-client.js +451 -325
- package/build/api-client.js.map +1 -1
- package/build/worker-compat.js +4227 -2968
- package/build/worker-compat.js.map +1 -1
- package/build/worker.js +408 -340
- package/build/worker.js.map +1 -1
- package/package.json +2 -2
- package/src/constants.ts +12 -0
- package/src/fetch-map/layer-map.ts +2 -1
- 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/types.ts +1 -1
- package/src/utils/CellSet.ts +90 -0
- package/src/widget-sources/widget-remote-source.ts +5 -5
- package/src/widget-sources/widget-tileset-source-impl.ts +15 -10
package/build/api-client.cjs
CHANGED
|
@@ -99,9 +99,11 @@ var require_thenBy_module = __commonJS({
|
|
|
99
99
|
// src/index.ts
|
|
100
100
|
var src_exports = {};
|
|
101
101
|
__export(src_exports, {
|
|
102
|
+
AggregationTypes: () => AggregationTypes,
|
|
102
103
|
ApiVersion: () => ApiVersion,
|
|
103
104
|
BASEMAP: () => basemap_styles_default,
|
|
104
105
|
CartoAPIError: () => CartoAPIError,
|
|
106
|
+
CellSet: () => CellSet,
|
|
105
107
|
DEFAULT_API_BASE_URL: () => DEFAULT_API_BASE_URL,
|
|
106
108
|
FEATURE_GEOM_PROPERTY: () => FEATURE_GEOM_PROPERTY,
|
|
107
109
|
FilterType: () => FilterType,
|
|
@@ -210,11 +212,11 @@ var FilterType = /* @__PURE__ */ ((FilterType2) => {
|
|
|
210
212
|
FilterType2["STRING_SEARCH"] = "stringSearch";
|
|
211
213
|
return FilterType2;
|
|
212
214
|
})(FilterType || {});
|
|
213
|
-
var ApiVersion = /* @__PURE__ */ ((
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
return
|
|
215
|
+
var ApiVersion = /* @__PURE__ */ ((ApiVersion3) => {
|
|
216
|
+
ApiVersion3["V1"] = "v1";
|
|
217
|
+
ApiVersion3["V2"] = "v2";
|
|
218
|
+
ApiVersion3["V3"] = "v3";
|
|
219
|
+
return ApiVersion3;
|
|
218
220
|
})(ApiVersion || {});
|
|
219
221
|
var DEFAULT_API_BASE_URL = "https://gcp-us-east1.api.carto.com";
|
|
220
222
|
var TileFormat = /* @__PURE__ */ ((TileFormat2) => {
|
|
@@ -242,6 +244,14 @@ var SpatialIndexColumn = Object.freeze({
|
|
|
242
244
|
["h3" /* H3 */]: ["h3", "hex", "h3id", "hex_id", "h3hex"],
|
|
243
245
|
["quadbin" /* QUADBIN */]: ["quadbin"]
|
|
244
246
|
});
|
|
247
|
+
var AggregationTypes = {
|
|
248
|
+
Count: "count",
|
|
249
|
+
Avg: "avg",
|
|
250
|
+
Min: "min",
|
|
251
|
+
Max: "max",
|
|
252
|
+
Sum: "sum",
|
|
253
|
+
Custom: "custom"
|
|
254
|
+
};
|
|
245
255
|
|
|
246
256
|
// src/deck/get-data-filter-extension-props.ts
|
|
247
257
|
init_cjs_shims();
|
|
@@ -1717,6 +1727,143 @@ init_cjs_shims();
|
|
|
1717
1727
|
// src/filters/tileFeaturesGeometries.ts
|
|
1718
1728
|
init_cjs_shims();
|
|
1719
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
|
+
|
|
1720
1867
|
// node_modules/@turf/bbox-polygon/dist/esm/index.js
|
|
1721
1868
|
init_cjs_shims();
|
|
1722
1869
|
function bboxPolygon(bbox2, options = {}) {
|
|
@@ -2048,7 +2195,7 @@ var MAX_SAFE_INTEGER = 9007199254740991;
|
|
|
2048
2195
|
var POWS_TEN = [1, 10, 100, 1e3, 1e4, 1e5, 1e6, 1e7, 1e8, 1e9, 1e10, 1e11, 1e12, 1e13];
|
|
2049
2196
|
var SQRT_BASE = 1e7;
|
|
2050
2197
|
var MAX = 1e9;
|
|
2051
|
-
function
|
|
2198
|
+
function clone2(configObject) {
|
|
2052
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 = {
|
|
2053
2200
|
prefix: "",
|
|
2054
2201
|
groupSize: 3,
|
|
@@ -2174,7 +2321,7 @@ function clone(configObject) {
|
|
|
2174
2321
|
x.c = [x.e = 0];
|
|
2175
2322
|
}
|
|
2176
2323
|
}
|
|
2177
|
-
BigNumber2.clone =
|
|
2324
|
+
BigNumber2.clone = clone2;
|
|
2178
2325
|
BigNumber2.ROUND_UP = 0;
|
|
2179
2326
|
BigNumber2.ROUND_DOWN = 1;
|
|
2180
2327
|
BigNumber2.ROUND_CEIL = 2;
|
|
@@ -3377,7 +3524,7 @@ function toFixedPoint(str, e, z) {
|
|
|
3377
3524
|
}
|
|
3378
3525
|
return str;
|
|
3379
3526
|
}
|
|
3380
|
-
var BigNumber =
|
|
3527
|
+
var BigNumber = clone2();
|
|
3381
3528
|
var bignumber_default = BigNumber;
|
|
3382
3529
|
|
|
3383
3530
|
// node_modules/splaytree-ts/dist/esm/index.js
|
|
@@ -4950,99 +5097,13 @@ var turf_intersect_default = intersect;
|
|
|
4950
5097
|
|
|
4951
5098
|
// src/utils/transformToTileCoords.ts
|
|
4952
5099
|
init_cjs_shims();
|
|
4953
|
-
|
|
4954
|
-
|
|
4955
|
-
|
|
4956
|
-
|
|
4957
|
-
|
|
4958
|
-
|
|
4959
|
-
|
|
4960
|
-
// node_modules/@math.gl/web-mercator/dist/math-utils.js
|
|
4961
|
-
init_cjs_shims();
|
|
4962
|
-
|
|
4963
|
-
// node_modules/@math.gl/core/dist/index.js
|
|
4964
|
-
init_cjs_shims();
|
|
4965
|
-
|
|
4966
|
-
// node_modules/@math.gl/core/dist/lib/common.js
|
|
4967
|
-
init_cjs_shims();
|
|
4968
|
-
var RADIANS_TO_DEGREES = 1 / Math.PI * 180;
|
|
4969
|
-
var DEGREES_TO_RADIANS = 1 / 180 * Math.PI;
|
|
4970
|
-
var DEFAULT_CONFIG = {
|
|
4971
|
-
EPSILON: 1e-12,
|
|
4972
|
-
debug: false,
|
|
4973
|
-
precision: 4,
|
|
4974
|
-
printTypes: false,
|
|
4975
|
-
printDegrees: false,
|
|
4976
|
-
printRowMajor: true,
|
|
4977
|
-
_cartographicRadians: false
|
|
4978
|
-
};
|
|
4979
|
-
globalThis.mathgl = globalThis.mathgl || { config: { ...DEFAULT_CONFIG } };
|
|
4980
|
-
var config = globalThis.mathgl.config;
|
|
4981
|
-
function isArray(value) {
|
|
4982
|
-
return Array.isArray(value) || ArrayBuffer.isView(value) && !(value instanceof DataView);
|
|
4983
|
-
}
|
|
4984
|
-
function lerp(a, b, t) {
|
|
4985
|
-
if (isArray(a)) {
|
|
4986
|
-
return a.map((ai, i) => lerp(ai, b[i], t));
|
|
4987
|
-
}
|
|
4988
|
-
return t * b + (1 - t) * a;
|
|
4989
|
-
}
|
|
4990
|
-
|
|
4991
|
-
// node_modules/@math.gl/web-mercator/dist/web-mercator-utils.js
|
|
4992
|
-
init_cjs_shims();
|
|
4993
|
-
|
|
4994
|
-
// node_modules/@math.gl/web-mercator/dist/assert.js
|
|
4995
|
-
init_cjs_shims();
|
|
4996
|
-
function assert(condition, message) {
|
|
4997
|
-
if (!condition) {
|
|
4998
|
-
throw new Error(message || "@math.gl/web-mercator: assertion failed.");
|
|
4999
|
-
}
|
|
5000
|
-
}
|
|
5001
|
-
|
|
5002
|
-
// node_modules/@math.gl/web-mercator/dist/web-mercator-utils.js
|
|
5003
|
-
var PI = Math.PI;
|
|
5004
|
-
var PI_4 = PI / 4;
|
|
5005
|
-
var DEGREES_TO_RADIANS2 = PI / 180;
|
|
5006
|
-
var RADIANS_TO_DEGREES2 = 180 / PI;
|
|
5007
|
-
var TILE_SIZE = 512;
|
|
5008
|
-
function lngLatToWorld(lngLat) {
|
|
5009
|
-
const [lng, lat] = lngLat;
|
|
5010
|
-
assert(Number.isFinite(lng));
|
|
5011
|
-
assert(Number.isFinite(lat) && lat >= -90 && lat <= 90, "invalid latitude");
|
|
5012
|
-
const lambda2 = lng * DEGREES_TO_RADIANS2;
|
|
5013
|
-
const phi2 = lat * DEGREES_TO_RADIANS2;
|
|
5014
|
-
const x = TILE_SIZE * (lambda2 + PI) / (2 * PI);
|
|
5015
|
-
const y = TILE_SIZE * (PI + Math.log(Math.tan(PI_4 + phi2 * 0.5))) / (2 * PI);
|
|
5016
|
-
return [x, y];
|
|
5017
|
-
}
|
|
5018
|
-
function worldToLngLat(xy) {
|
|
5019
|
-
const [x, y] = xy;
|
|
5020
|
-
const lambda2 = x / TILE_SIZE * (2 * PI) - PI;
|
|
5021
|
-
const phi2 = 2 * (Math.atan(Math.exp(y / TILE_SIZE * (2 * PI) - PI)) - PI_4);
|
|
5022
|
-
return [lambda2 * RADIANS_TO_DEGREES2, phi2 * RADIANS_TO_DEGREES2];
|
|
5023
|
-
}
|
|
5024
|
-
|
|
5025
|
-
// node_modules/@math.gl/web-mercator/dist/fit-bounds.js
|
|
5026
|
-
init_cjs_shims();
|
|
5027
|
-
|
|
5028
|
-
// node_modules/@math.gl/web-mercator/dist/get-bounds.js
|
|
5029
|
-
init_cjs_shims();
|
|
5030
|
-
var DEGREES_TO_RADIANS3 = Math.PI / 180;
|
|
5031
|
-
|
|
5032
|
-
// node_modules/@math.gl/web-mercator/dist/normalize-viewport-props.js
|
|
5033
|
-
init_cjs_shims();
|
|
5034
|
-
|
|
5035
|
-
// node_modules/@math.gl/web-mercator/dist/fly-to-viewport.js
|
|
5036
|
-
init_cjs_shims();
|
|
5037
|
-
|
|
5038
|
-
// src/utils/transformToTileCoords.ts
|
|
5039
|
-
var TRANSFORM_FN = {
|
|
5040
|
-
Point: transformPoint,
|
|
5041
|
-
MultiPoint: transformMultiPoint,
|
|
5042
|
-
LineString: transformLineString,
|
|
5043
|
-
MultiLineString: transformMultiLineString,
|
|
5044
|
-
Polygon: transformPolygon,
|
|
5045
|
-
MultiPolygon: transformMultiPolygon
|
|
5100
|
+
var TRANSFORM_FN2 = {
|
|
5101
|
+
Point: transformPoint2,
|
|
5102
|
+
MultiPoint: transformMultiPoint2,
|
|
5103
|
+
LineString: transformLineString2,
|
|
5104
|
+
MultiLineString: transformMultiLineString2,
|
|
5105
|
+
Polygon: transformPolygon2,
|
|
5106
|
+
MultiPolygon: transformMultiPolygon2
|
|
5046
5107
|
};
|
|
5047
5108
|
function transformToTileCoords(geometry, bbox2) {
|
|
5048
5109
|
const [west, south, east, north] = bbox2;
|
|
@@ -5052,34 +5113,34 @@ function transformToTileCoords(geometry, bbox2) {
|
|
|
5052
5113
|
if (geometry.type === "GeometryCollection") {
|
|
5053
5114
|
throw new Error("Unsupported geometry type GeometryCollection");
|
|
5054
5115
|
}
|
|
5055
|
-
const transformFn =
|
|
5116
|
+
const transformFn = TRANSFORM_FN2[geometry.type];
|
|
5056
5117
|
const coordinates = transformFn(geometry.coordinates, projectedBbox);
|
|
5057
5118
|
return { ...geometry, coordinates };
|
|
5058
5119
|
}
|
|
5059
|
-
function
|
|
5120
|
+
function transformPoint2([pointX, pointY], [nw, se]) {
|
|
5060
5121
|
const x = inverseLerp(nw[0], se[0], pointX);
|
|
5061
5122
|
const y = inverseLerp(nw[1], se[1], pointY);
|
|
5062
5123
|
return [x, y];
|
|
5063
5124
|
}
|
|
5064
|
-
function
|
|
5065
|
-
return geometry.map((g) =>
|
|
5125
|
+
function getPoints2(geometry, bbox2) {
|
|
5126
|
+
return geometry.map((g) => transformPoint2(projectFlat(g), bbox2));
|
|
5066
5127
|
}
|
|
5067
|
-
function
|
|
5068
|
-
return
|
|
5128
|
+
function transformMultiPoint2(multiPoint, bbox2) {
|
|
5129
|
+
return getPoints2(multiPoint, bbox2);
|
|
5069
5130
|
}
|
|
5070
|
-
function
|
|
5071
|
-
return
|
|
5131
|
+
function transformLineString2(line, bbox2) {
|
|
5132
|
+
return getPoints2(line, bbox2);
|
|
5072
5133
|
}
|
|
5073
|
-
function
|
|
5134
|
+
function transformMultiLineString2(multiLineString2, bbox2) {
|
|
5074
5135
|
return multiLineString2.map(
|
|
5075
|
-
(lineString2) =>
|
|
5136
|
+
(lineString2) => transformLineString2(lineString2, bbox2)
|
|
5076
5137
|
);
|
|
5077
5138
|
}
|
|
5078
|
-
function
|
|
5079
|
-
return polygon2.map((polygonRing) =>
|
|
5139
|
+
function transformPolygon2(polygon2, bbox2) {
|
|
5140
|
+
return polygon2.map((polygonRing) => getPoints2(polygonRing, bbox2));
|
|
5080
5141
|
}
|
|
5081
|
-
function
|
|
5082
|
-
return multiPolygon2.map((polygon2) =>
|
|
5142
|
+
function transformMultiPolygon2(multiPolygon2, bbox2) {
|
|
5143
|
+
return multiPolygon2.map((polygon2) => transformPolygon2(polygon2, bbox2));
|
|
5083
5144
|
}
|
|
5084
5145
|
function projectFlat(xyz) {
|
|
5085
5146
|
return lngLatToWorld(xyz);
|
|
@@ -5088,52 +5149,190 @@ function inverseLerp(a, b, x) {
|
|
|
5088
5149
|
return (x - a) / (b - a);
|
|
5089
5150
|
}
|
|
5090
5151
|
|
|
5091
|
-
// 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
|
|
5092
5157
|
init_cjs_shims();
|
|
5093
|
-
|
|
5094
|
-
|
|
5095
|
-
|
|
5096
|
-
|
|
5097
|
-
|
|
5098
|
-
|
|
5099
|
-
|
|
5100
|
-
|
|
5101
|
-
|
|
5102
|
-
|
|
5103
|
-
|
|
5104
|
-
|
|
5105
|
-
|
|
5106
|
-
|
|
5107
|
-
|
|
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;
|
|
5108
5191
|
}
|
|
5109
|
-
|
|
5110
|
-
|
|
5111
|
-
|
|
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;
|
|
5112
5213
|
}
|
|
5113
|
-
function
|
|
5114
|
-
|
|
5115
|
-
const y = lerp(nw[1], se[1], pointY);
|
|
5116
|
-
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;
|
|
5117
5216
|
}
|
|
5118
|
-
function
|
|
5119
|
-
|
|
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;
|
|
5120
5224
|
}
|
|
5121
|
-
function
|
|
5122
|
-
|
|
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
|
+
}
|
|
5123
5257
|
}
|
|
5124
|
-
function
|
|
5125
|
-
|
|
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;
|
|
5126
5272
|
}
|
|
5127
|
-
|
|
5128
|
-
|
|
5129
|
-
|
|
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)])
|
|
5130
5283
|
);
|
|
5284
|
+
if (!clippedSpatialFilter) {
|
|
5285
|
+
return false;
|
|
5286
|
+
}
|
|
5287
|
+
return tileFormat === "mvt" /* MVT */ ? transformToTileCoords(clippedSpatialFilter.geometry, tileBbox) : clippedSpatialFilter.geometry;
|
|
5131
5288
|
}
|
|
5132
|
-
function
|
|
5133
|
-
return
|
|
5289
|
+
function intersectTileRaster(parent, cellResolution, spatialFilter) {
|
|
5290
|
+
return intersectTileQuadbin(parent, cellResolution, spatialFilter);
|
|
5134
5291
|
}
|
|
5135
|
-
function
|
|
5136
|
-
|
|
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));
|
|
5137
5336
|
}
|
|
5138
5337
|
|
|
5139
5338
|
// src/filters/tileFeaturesGeometries.ts
|
|
@@ -5150,55 +5349,45 @@ function tileFeaturesGeometries({
|
|
|
5150
5349
|
if (tile.isVisible === false || !tile.data) {
|
|
5151
5350
|
continue;
|
|
5152
5351
|
}
|
|
5153
|
-
const
|
|
5352
|
+
const tileBbox = [
|
|
5154
5353
|
tile.bbox.west,
|
|
5155
5354
|
tile.bbox.south,
|
|
5156
5355
|
tile.bbox.east,
|
|
5157
5356
|
tile.bbox.north
|
|
5158
5357
|
];
|
|
5159
|
-
const
|
|
5160
|
-
|
|
5161
|
-
|
|
5162
|
-
|
|
5163
|
-
geometry: spatialFilter,
|
|
5164
|
-
properties: {}
|
|
5165
|
-
};
|
|
5166
|
-
const clippedGeometryToIntersect = turf_intersect_default(
|
|
5167
|
-
featureCollection([bboxToGeom, spatialFilterFeature])
|
|
5358
|
+
const intersection3 = intersectTileGeometry(
|
|
5359
|
+
tileBbox,
|
|
5360
|
+
tileFormat,
|
|
5361
|
+
spatialFilter
|
|
5168
5362
|
);
|
|
5169
|
-
if (
|
|
5170
|
-
|
|
5171
|
-
}
|
|
5172
|
-
const transformedGeometryToIntersect = tileFormat === "mvt" /* MVT */ ? transformToTileCoords(clippedGeometryToIntersect.geometry, bbox2) : clippedGeometryToIntersect.geometry;
|
|
5363
|
+
if (intersection3 === false) continue;
|
|
5364
|
+
const transformedSpatialFilter = intersection3 === true ? void 0 : intersection3;
|
|
5173
5365
|
calculateFeatures({
|
|
5174
5366
|
map,
|
|
5175
|
-
|
|
5176
|
-
geometryIntersection: transformedGeometryToIntersect,
|
|
5367
|
+
spatialFilter: transformedSpatialFilter,
|
|
5177
5368
|
data: tile.data.points,
|
|
5178
5369
|
type: "Point",
|
|
5179
|
-
bbox:
|
|
5370
|
+
bbox: tileBbox,
|
|
5180
5371
|
tileFormat,
|
|
5181
5372
|
uniqueIdProperty,
|
|
5182
5373
|
options
|
|
5183
5374
|
});
|
|
5184
5375
|
calculateFeatures({
|
|
5185
5376
|
map,
|
|
5186
|
-
|
|
5187
|
-
geometryIntersection: transformedGeometryToIntersect,
|
|
5377
|
+
spatialFilter: transformedSpatialFilter,
|
|
5188
5378
|
data: tile.data.lines,
|
|
5189
5379
|
type: "LineString",
|
|
5190
|
-
bbox:
|
|
5380
|
+
bbox: tileBbox,
|
|
5191
5381
|
tileFormat,
|
|
5192
5382
|
uniqueIdProperty,
|
|
5193
5383
|
options
|
|
5194
5384
|
});
|
|
5195
5385
|
calculateFeatures({
|
|
5196
5386
|
map,
|
|
5197
|
-
|
|
5198
|
-
geometryIntersection: transformedGeometryToIntersect,
|
|
5387
|
+
spatialFilter: transformedSpatialFilter,
|
|
5199
5388
|
data: tile.data.polygons,
|
|
5200
5389
|
type: "Polygon",
|
|
5201
|
-
bbox:
|
|
5390
|
+
bbox: tileBbox,
|
|
5202
5391
|
tileFormat,
|
|
5203
5392
|
uniqueIdProperty,
|
|
5204
5393
|
options
|
|
@@ -5216,7 +5405,7 @@ function processTileFeatureProperties({
|
|
|
5216
5405
|
tileFormat,
|
|
5217
5406
|
uniqueIdProperty,
|
|
5218
5407
|
storeGeometry,
|
|
5219
|
-
|
|
5408
|
+
spatialFilter
|
|
5220
5409
|
}) {
|
|
5221
5410
|
const tileProps = getPropertiesFromTile(data, startIndex);
|
|
5222
5411
|
const uniquePropertyValue = getUniquePropertyValue(
|
|
@@ -5228,7 +5417,7 @@ function processTileFeatureProperties({
|
|
|
5228
5417
|
return;
|
|
5229
5418
|
}
|
|
5230
5419
|
let geometry = null;
|
|
5231
|
-
if (storeGeometry ||
|
|
5420
|
+
if (storeGeometry || spatialFilter) {
|
|
5232
5421
|
const { positions } = data;
|
|
5233
5422
|
const ringCoordinates = getRingCoordinatesFor(
|
|
5234
5423
|
startIndex,
|
|
@@ -5237,7 +5426,7 @@ function processTileFeatureProperties({
|
|
|
5237
5426
|
);
|
|
5238
5427
|
geometry = getFeatureByType(ringCoordinates, type);
|
|
5239
5428
|
}
|
|
5240
|
-
if (geometry &&
|
|
5429
|
+
if (geometry && spatialFilter && !turf_boolean_intersects_default(geometry, spatialFilter)) {
|
|
5241
5430
|
return;
|
|
5242
5431
|
}
|
|
5243
5432
|
const properties = parseProperties(tileProps);
|
|
@@ -5249,7 +5438,7 @@ function processTileFeatureProperties({
|
|
|
5249
5438
|
function addIntersectedFeaturesInTile({
|
|
5250
5439
|
map,
|
|
5251
5440
|
data,
|
|
5252
|
-
|
|
5441
|
+
spatialFilter,
|
|
5253
5442
|
type,
|
|
5254
5443
|
bbox: bbox2,
|
|
5255
5444
|
tileFormat,
|
|
@@ -5271,7 +5460,7 @@ function addIntersectedFeaturesInTile({
|
|
|
5271
5460
|
tileFormat,
|
|
5272
5461
|
uniqueIdProperty,
|
|
5273
5462
|
storeGeometry,
|
|
5274
|
-
|
|
5463
|
+
spatialFilter
|
|
5275
5464
|
});
|
|
5276
5465
|
}
|
|
5277
5466
|
}
|
|
@@ -5353,8 +5542,7 @@ function getRingCoordinatesFor(startIndex, endIndex, positions) {
|
|
|
5353
5542
|
}
|
|
5354
5543
|
function calculateFeatures({
|
|
5355
5544
|
map,
|
|
5356
|
-
|
|
5357
|
-
geometryIntersection,
|
|
5545
|
+
spatialFilter,
|
|
5358
5546
|
data,
|
|
5359
5547
|
type,
|
|
5360
5548
|
bbox: bbox2,
|
|
@@ -5365,7 +5553,7 @@ function calculateFeatures({
|
|
|
5365
5553
|
if (!data?.properties.length) {
|
|
5366
5554
|
return;
|
|
5367
5555
|
}
|
|
5368
|
-
if (
|
|
5556
|
+
if (!spatialFilter) {
|
|
5369
5557
|
addAllFeaturesInTile({
|
|
5370
5558
|
map,
|
|
5371
5559
|
data,
|
|
@@ -5379,7 +5567,7 @@ function calculateFeatures({
|
|
|
5379
5567
|
addIntersectedFeaturesInTile({
|
|
5380
5568
|
map,
|
|
5381
5569
|
data,
|
|
5382
|
-
|
|
5570
|
+
spatialFilter,
|
|
5383
5571
|
type,
|
|
5384
5572
|
bbox: bbox2,
|
|
5385
5573
|
tileFormat,
|
|
@@ -5430,129 +5618,8 @@ function createIndicesForPoints(data) {
|
|
|
5430
5618
|
|
|
5431
5619
|
// src/filters/tileFeaturesSpatialIndex.ts
|
|
5432
5620
|
init_cjs_shims();
|
|
5433
|
-
var
|
|
5434
|
-
|
|
5435
|
-
// node_modules/@turf/bbox-clip/dist/esm/index.js
|
|
5436
|
-
init_cjs_shims();
|
|
5437
|
-
function lineclip(points, bbox2, result) {
|
|
5438
|
-
var len = points.length, codeA = bitCode(points[0], bbox2), part = [], i, codeB, lastCode;
|
|
5439
|
-
let a;
|
|
5440
|
-
let b;
|
|
5441
|
-
if (!result) result = [];
|
|
5442
|
-
for (i = 1; i < len; i++) {
|
|
5443
|
-
a = points[i - 1];
|
|
5444
|
-
b = points[i];
|
|
5445
|
-
codeB = lastCode = bitCode(b, bbox2);
|
|
5446
|
-
while (true) {
|
|
5447
|
-
if (!(codeA | codeB)) {
|
|
5448
|
-
part.push(a);
|
|
5449
|
-
if (codeB !== lastCode) {
|
|
5450
|
-
part.push(b);
|
|
5451
|
-
if (i < len - 1) {
|
|
5452
|
-
result.push(part);
|
|
5453
|
-
part = [];
|
|
5454
|
-
}
|
|
5455
|
-
} else if (i === len - 1) {
|
|
5456
|
-
part.push(b);
|
|
5457
|
-
}
|
|
5458
|
-
break;
|
|
5459
|
-
} else if (codeA & codeB) {
|
|
5460
|
-
break;
|
|
5461
|
-
} else if (codeA) {
|
|
5462
|
-
a = intersect2(a, b, codeA, bbox2);
|
|
5463
|
-
codeA = bitCode(a, bbox2);
|
|
5464
|
-
} else {
|
|
5465
|
-
b = intersect2(a, b, codeB, bbox2);
|
|
5466
|
-
codeB = bitCode(b, bbox2);
|
|
5467
|
-
}
|
|
5468
|
-
}
|
|
5469
|
-
codeA = lastCode;
|
|
5470
|
-
}
|
|
5471
|
-
if (part.length) result.push(part);
|
|
5472
|
-
return result;
|
|
5473
|
-
}
|
|
5474
|
-
function polygonclip(points, bbox2) {
|
|
5475
|
-
var result, edge, prev, prevInside, i, p, inside;
|
|
5476
|
-
for (edge = 1; edge <= 8; edge *= 2) {
|
|
5477
|
-
result = [];
|
|
5478
|
-
prev = points[points.length - 1];
|
|
5479
|
-
prevInside = !(bitCode(prev, bbox2) & edge);
|
|
5480
|
-
for (i = 0; i < points.length; i++) {
|
|
5481
|
-
p = points[i];
|
|
5482
|
-
inside = !(bitCode(p, bbox2) & edge);
|
|
5483
|
-
if (inside !== prevInside) result.push(intersect2(prev, p, edge, bbox2));
|
|
5484
|
-
if (inside) result.push(p);
|
|
5485
|
-
prev = p;
|
|
5486
|
-
prevInside = inside;
|
|
5487
|
-
}
|
|
5488
|
-
points = result;
|
|
5489
|
-
if (!points.length) break;
|
|
5490
|
-
}
|
|
5491
|
-
return result;
|
|
5492
|
-
}
|
|
5493
|
-
function intersect2(a, b, edge, bbox2) {
|
|
5494
|
-
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;
|
|
5495
|
-
}
|
|
5496
|
-
function bitCode(p, bbox2) {
|
|
5497
|
-
var code = 0;
|
|
5498
|
-
if (p[0] < bbox2[0]) code |= 1;
|
|
5499
|
-
else if (p[0] > bbox2[2]) code |= 2;
|
|
5500
|
-
if (p[1] < bbox2[1]) code |= 4;
|
|
5501
|
-
else if (p[1] > bbox2[3]) code |= 8;
|
|
5502
|
-
return code;
|
|
5503
|
-
}
|
|
5504
|
-
function bboxClip(feature2, bbox2) {
|
|
5505
|
-
const geom = getGeom(feature2);
|
|
5506
|
-
const type = geom.type;
|
|
5507
|
-
const properties = feature2.type === "Feature" ? feature2.properties : {};
|
|
5508
|
-
let coords = geom.coordinates;
|
|
5509
|
-
switch (type) {
|
|
5510
|
-
case "LineString":
|
|
5511
|
-
case "MultiLineString": {
|
|
5512
|
-
const lines = [];
|
|
5513
|
-
if (type === "LineString") {
|
|
5514
|
-
coords = [coords];
|
|
5515
|
-
}
|
|
5516
|
-
coords.forEach((line) => {
|
|
5517
|
-
lineclip(line, bbox2, lines);
|
|
5518
|
-
});
|
|
5519
|
-
if (lines.length === 1) {
|
|
5520
|
-
return lineString(lines[0], properties);
|
|
5521
|
-
}
|
|
5522
|
-
return multiLineString(lines, properties);
|
|
5523
|
-
}
|
|
5524
|
-
case "Polygon":
|
|
5525
|
-
return polygon(clipPolygon(coords, bbox2), properties);
|
|
5526
|
-
case "MultiPolygon":
|
|
5527
|
-
return multiPolygon(
|
|
5528
|
-
coords.map((poly) => {
|
|
5529
|
-
return clipPolygon(poly, bbox2);
|
|
5530
|
-
}),
|
|
5531
|
-
properties
|
|
5532
|
-
);
|
|
5533
|
-
default:
|
|
5534
|
-
throw new Error("geometry " + type + " not supported");
|
|
5535
|
-
}
|
|
5536
|
-
}
|
|
5537
|
-
function clipPolygon(rings, bbox2) {
|
|
5538
|
-
const outRings = [];
|
|
5539
|
-
for (const ring of rings) {
|
|
5540
|
-
const clipped = polygonclip(ring, bbox2);
|
|
5541
|
-
if (clipped.length > 0) {
|
|
5542
|
-
if (clipped[0][0] !== clipped[clipped.length - 1][0] || clipped[0][1] !== clipped[clipped.length - 1][1]) {
|
|
5543
|
-
clipped.push(clipped[0]);
|
|
5544
|
-
}
|
|
5545
|
-
if (clipped.length >= 4) {
|
|
5546
|
-
outRings.push(clipped);
|
|
5547
|
-
}
|
|
5548
|
-
}
|
|
5549
|
-
}
|
|
5550
|
-
return outRings;
|
|
5551
|
-
}
|
|
5552
|
-
var turf_bbox_clip_default = bboxClip;
|
|
5553
|
-
|
|
5554
|
-
// src/filters/tileFeaturesSpatialIndex.ts
|
|
5555
|
-
var import_h3_js = require("h3-js");
|
|
5621
|
+
var import_quadbin2 = require("quadbin");
|
|
5622
|
+
var import_h3_js2 = require("h3-js");
|
|
5556
5623
|
function tileFeaturesSpatialIndex({
|
|
5557
5624
|
tiles,
|
|
5558
5625
|
spatialFilter,
|
|
@@ -5561,58 +5628,50 @@ function tileFeaturesSpatialIndex({
|
|
|
5561
5628
|
}) {
|
|
5562
5629
|
const map = /* @__PURE__ */ new Map();
|
|
5563
5630
|
const spatialIndex = getSpatialIndex(spatialDataType);
|
|
5564
|
-
const
|
|
5631
|
+
const cellResolution = getResolution(tiles, spatialIndex);
|
|
5565
5632
|
const spatialIndexIDName = spatialDataColumn ? spatialDataColumn : spatialIndex;
|
|
5566
|
-
if (!
|
|
5567
|
-
return [];
|
|
5568
|
-
}
|
|
5569
|
-
const cells = getCellsCoverGeometry(spatialFilter, spatialIndex, resolution);
|
|
5570
|
-
if (!cells?.length) {
|
|
5633
|
+
if (!cellResolution) {
|
|
5571
5634
|
return [];
|
|
5572
5635
|
}
|
|
5573
|
-
const cellsSet = new Set(cells);
|
|
5574
5636
|
for (const tile of tiles) {
|
|
5575
5637
|
if (tile.isVisible === false || !tile.data) {
|
|
5576
5638
|
continue;
|
|
5577
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;
|
|
5578
5651
|
tile.data.forEach((d) => {
|
|
5579
|
-
if (
|
|
5652
|
+
if (intersection3 === true || intersection3.has(d.id)) {
|
|
5580
5653
|
map.set(d.id, { ...d.properties, [spatialIndexIDName]: d.id });
|
|
5581
5654
|
}
|
|
5582
5655
|
});
|
|
5583
5656
|
}
|
|
5584
5657
|
return Array.from(map.values());
|
|
5585
5658
|
}
|
|
5659
|
+
function getTileIndex(tile, spatialIndex) {
|
|
5660
|
+
if (spatialIndex === "quadbin" /* QUADBIN */) {
|
|
5661
|
+
return tile.index.q;
|
|
5662
|
+
}
|
|
5663
|
+
return tile.id;
|
|
5664
|
+
}
|
|
5586
5665
|
function getResolution(tiles, spatialIndex) {
|
|
5587
5666
|
const data = tiles.find((tile) => tile.data?.length)?.data;
|
|
5588
5667
|
if (!data) {
|
|
5589
5668
|
return;
|
|
5590
5669
|
}
|
|
5591
5670
|
if (spatialIndex === "quadbin" /* QUADBIN */) {
|
|
5592
|
-
return Number((0,
|
|
5593
|
-
}
|
|
5594
|
-
if (spatialIndex === "h3" /* H3 */) {
|
|
5595
|
-
return (0, import_h3_js.getResolution)(data[0].id);
|
|
5596
|
-
}
|
|
5597
|
-
}
|
|
5598
|
-
var bboxWest = [-180, -90, 0, 90];
|
|
5599
|
-
var bboxEast = [0, -90, 180, 90];
|
|
5600
|
-
function getCellsCoverGeometry(geometry, spatialIndex, resolution) {
|
|
5601
|
-
if (spatialIndex === "quadbin" /* QUADBIN */) {
|
|
5602
|
-
return (0, import_quadbin.geometryToCells)(geometry, resolution);
|
|
5671
|
+
return Number((0, import_quadbin2.getResolution)(data[0].id));
|
|
5603
5672
|
}
|
|
5604
5673
|
if (spatialIndex === "h3" /* H3 */) {
|
|
5605
|
-
return (0,
|
|
5606
|
-
turf_bbox_clip_default(geometry, bboxWest).geometry.coordinates,
|
|
5607
|
-
resolution,
|
|
5608
|
-
true
|
|
5609
|
-
).concat(
|
|
5610
|
-
(0, import_h3_js.polygonToCells)(
|
|
5611
|
-
turf_bbox_clip_default(geometry, bboxEast).geometry.coordinates,
|
|
5612
|
-
resolution,
|
|
5613
|
-
true
|
|
5614
|
-
)
|
|
5615
|
-
);
|
|
5674
|
+
return (0, import_h3_js2.getResolution)(data[0].id);
|
|
5616
5675
|
}
|
|
5617
5676
|
}
|
|
5618
5677
|
function getSpatialIndex(spatialDataType) {
|
|
@@ -5640,7 +5699,7 @@ var DEFAULT_AGGREGATION_EXP = `1 AS ${DEFAULT_AGGREGATION_EXP_ALIAS}`;
|
|
|
5640
5699
|
|
|
5641
5700
|
// src/filters/tileFeaturesRaster.ts
|
|
5642
5701
|
init_cjs_shims();
|
|
5643
|
-
var
|
|
5702
|
+
var import_quadbin3 = require("quadbin");
|
|
5644
5703
|
function tileFeaturesRaster({
|
|
5645
5704
|
tiles,
|
|
5646
5705
|
...options
|
|
@@ -5651,18 +5710,23 @@ function tileFeaturesRaster({
|
|
|
5651
5710
|
}
|
|
5652
5711
|
tiles = tiles.filter(isRasterTileVisible);
|
|
5653
5712
|
if (tiles.length === 0) return [];
|
|
5654
|
-
const tileResolution = (0,
|
|
5713
|
+
const tileResolution = (0, import_quadbin3.getResolution)(tiles[0].index.q);
|
|
5655
5714
|
const tileBlockSize = tiles[0].data.blockSize;
|
|
5656
5715
|
const cellResolution = tileResolution + BigInt(Math.log2(tileBlockSize));
|
|
5657
|
-
const spatialFilterCells = new Set(
|
|
5658
|
-
(0, import_quadbin2.geometryToCells)(options.spatialFilter, cellResolution)
|
|
5659
|
-
);
|
|
5660
5716
|
const data = /* @__PURE__ */ new Map();
|
|
5661
5717
|
for (const tile of tiles) {
|
|
5662
5718
|
const parent = tile.index.q;
|
|
5663
|
-
const
|
|
5664
|
-
|
|
5665
|
-
|
|
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
|
+
}
|
|
5666
5730
|
const cellData = {};
|
|
5667
5731
|
let cellDataExists = false;
|
|
5668
5732
|
for (const band in tile.data.cells.numericProps) {
|
|
@@ -5674,7 +5738,7 @@ function tileFeaturesRaster({
|
|
|
5674
5738
|
}
|
|
5675
5739
|
}
|
|
5676
5740
|
if (cellDataExists) {
|
|
5677
|
-
data.set(
|
|
5741
|
+
data.set(tileSortedCells[i], cellData);
|
|
5678
5742
|
}
|
|
5679
5743
|
}
|
|
5680
5744
|
}
|
|
@@ -5687,10 +5751,10 @@ function isRasterTileVisible(tile) {
|
|
|
5687
5751
|
return !!(tile.isVisible && tile.data?.cells?.numericProps);
|
|
5688
5752
|
}
|
|
5689
5753
|
function cellToChildrenSorted(parent, resolution) {
|
|
5690
|
-
return (0,
|
|
5754
|
+
return (0, import_quadbin3.cellToChildren)(parent, resolution).sort(
|
|
5691
5755
|
(cellA, cellB) => {
|
|
5692
|
-
const tileA = (0,
|
|
5693
|
-
const tileB = (0,
|
|
5756
|
+
const tileA = (0, import_quadbin3.cellToTile)(cellA);
|
|
5757
|
+
const tileB = (0, import_quadbin3.cellToTile)(cellB);
|
|
5694
5758
|
if (tileA.y !== tileB.y) {
|
|
5695
5759
|
return tileA.y > tileB.y ? 1 : -1;
|
|
5696
5760
|
}
|
|
@@ -6520,7 +6584,7 @@ var WidgetRemoteSource = class extends WidgetSource {
|
|
|
6520
6584
|
...params
|
|
6521
6585
|
} = options;
|
|
6522
6586
|
const { column, operation: operation2, operationColumn, operationExp } = params;
|
|
6523
|
-
if (operation2 ===
|
|
6587
|
+
if (operation2 === AggregationTypes.Custom) {
|
|
6524
6588
|
assert2(operationExp, "operationExp is required for custom operation");
|
|
6525
6589
|
}
|
|
6526
6590
|
return executeModel({
|
|
@@ -6579,7 +6643,7 @@ var WidgetRemoteSource = class extends WidgetSource {
|
|
|
6579
6643
|
...params
|
|
6580
6644
|
} = options;
|
|
6581
6645
|
const { column, operation: operation2 } = params;
|
|
6582
|
-
if (operation2 ===
|
|
6646
|
+
if (operation2 === AggregationTypes.Custom) {
|
|
6583
6647
|
assert2(operationExp, "operationExp is required for custom operation");
|
|
6584
6648
|
}
|
|
6585
6649
|
return executeModel({
|
|
@@ -6591,7 +6655,7 @@ var WidgetRemoteSource = class extends WidgetSource {
|
|
|
6591
6655
|
},
|
|
6592
6656
|
params: {
|
|
6593
6657
|
column: column ?? "*",
|
|
6594
|
-
operation: operation2 ??
|
|
6658
|
+
operation: operation2 ?? AggregationTypes.Count,
|
|
6595
6659
|
operationExp
|
|
6596
6660
|
},
|
|
6597
6661
|
opts: { signal, headers: this.props.headers }
|
|
@@ -6727,7 +6791,7 @@ var WidgetRemoteSource = class extends WidgetSource {
|
|
|
6727
6791
|
splitByCategoryLimit,
|
|
6728
6792
|
splitByCategoryValues
|
|
6729
6793
|
} = params;
|
|
6730
|
-
if (operation2 ===
|
|
6794
|
+
if (operation2 === AggregationTypes.Custom) {
|
|
6731
6795
|
assert2(operationExp, "operationExp is required for custom operation");
|
|
6732
6796
|
}
|
|
6733
6797
|
return executeModel({
|
|
@@ -7451,7 +7515,7 @@ var WidgetTilesetSourceImpl = class extends WidgetSource {
|
|
|
7451
7515
|
}
|
|
7452
7516
|
_extractTileFeatures(spatialFilter) {
|
|
7453
7517
|
const prevInputs = this._tileFeatureExtractPreviousInputs;
|
|
7454
|
-
if (this._features.length &&
|
|
7518
|
+
if (this._features.length && spatialFilterEquals(prevInputs.spatialFilter, spatialFilter)) {
|
|
7455
7519
|
return;
|
|
7456
7520
|
}
|
|
7457
7521
|
this._features = tileFeatures({
|
|
@@ -7482,7 +7546,7 @@ var WidgetTilesetSourceImpl = class extends WidgetSource {
|
|
|
7482
7546
|
}
|
|
7483
7547
|
async getFormula({
|
|
7484
7548
|
column = "*",
|
|
7485
|
-
operation: operation2 =
|
|
7549
|
+
operation: operation2 = AggregationTypes.Count,
|
|
7486
7550
|
joinOperation,
|
|
7487
7551
|
filters,
|
|
7488
7552
|
filterOwner,
|
|
@@ -7493,13 +7557,13 @@ var WidgetTilesetSourceImpl = class extends WidgetSource {
|
|
|
7493
7557
|
filters,
|
|
7494
7558
|
filterOwner
|
|
7495
7559
|
);
|
|
7496
|
-
if (filteredFeatures.length === 0 && operation2 !==
|
|
7560
|
+
if (filteredFeatures.length === 0 && operation2 !== AggregationTypes.Count) {
|
|
7497
7561
|
return { value: null };
|
|
7498
7562
|
}
|
|
7499
|
-
if (operation2 ===
|
|
7563
|
+
if (operation2 === AggregationTypes.Custom) {
|
|
7500
7564
|
throw new Error("Custom aggregation not supported for tilesets");
|
|
7501
7565
|
}
|
|
7502
|
-
if (column && column !== "*" || operation2 !==
|
|
7566
|
+
if (column && column !== "*" || operation2 !== AggregationTypes.Count) {
|
|
7503
7567
|
assertColumn(this._features, column);
|
|
7504
7568
|
}
|
|
7505
7569
|
const targetOperation = aggregationFunctions[operation2];
|
|
@@ -7508,7 +7572,7 @@ var WidgetTilesetSourceImpl = class extends WidgetSource {
|
|
|
7508
7572
|
};
|
|
7509
7573
|
}
|
|
7510
7574
|
async getHistogram({
|
|
7511
|
-
operation: operation2 =
|
|
7575
|
+
operation: operation2 = AggregationTypes.Count,
|
|
7512
7576
|
ticks,
|
|
7513
7577
|
column,
|
|
7514
7578
|
joinOperation,
|
|
@@ -7535,7 +7599,7 @@ var WidgetTilesetSourceImpl = class extends WidgetSource {
|
|
|
7535
7599
|
}
|
|
7536
7600
|
async getCategories({
|
|
7537
7601
|
column,
|
|
7538
|
-
operation: operation2 =
|
|
7602
|
+
operation: operation2 = AggregationTypes.Count,
|
|
7539
7603
|
operationColumn,
|
|
7540
7604
|
joinOperation,
|
|
7541
7605
|
filters,
|
|
@@ -7691,7 +7755,6 @@ var WidgetTilesetSourceImpl = class extends WidgetSource {
|
|
|
7691
7755
|
* INTERNAL
|
|
7692
7756
|
*/
|
|
7693
7757
|
_getFilteredFeatures(spatialFilter, filters, filterOwner) {
|
|
7694
|
-
assert2(spatialFilter, "spatialFilter required for tilesets");
|
|
7695
7758
|
this._extractTileFeatures(spatialFilter);
|
|
7696
7759
|
return applyFilters(
|
|
7697
7760
|
this._features,
|
|
@@ -7715,6 +7778,11 @@ function assertColumn(features, ...columnArgs) {
|
|
|
7715
7778
|
function normalizeColumns(columns) {
|
|
7716
7779
|
return Array.isArray(columns) ? columns : typeof columns === "string" ? [columns] : [];
|
|
7717
7780
|
}
|
|
7781
|
+
function spatialFilterEquals(a, b) {
|
|
7782
|
+
if (a === b) return true;
|
|
7783
|
+
if (!a || !b) return false;
|
|
7784
|
+
return booleanEqual(a, b);
|
|
7785
|
+
}
|
|
7718
7786
|
|
|
7719
7787
|
// src/widget-sources/widget-tileset-source.ts
|
|
7720
7788
|
var WidgetTilesetSource = class extends WidgetSource {
|
|
@@ -9293,7 +9361,7 @@ function negateAccessor(accessor) {
|
|
|
9293
9361
|
function getSizeAccessor({ name }, scaleType, aggregation, range, data) {
|
|
9294
9362
|
const scale2 = scaleType ? SCALE_FUNCS[scaleType]() : identity2;
|
|
9295
9363
|
if (scaleType) {
|
|
9296
|
-
if (aggregation !==
|
|
9364
|
+
if (aggregation !== AggregationTypes.Count) {
|
|
9297
9365
|
scale2.domain(calculateDomain(data, name, scaleType));
|
|
9298
9366
|
}
|
|
9299
9367
|
scale2.range(range);
|
|
@@ -10279,11 +10347,70 @@ function _getHexagonResolution(viewport, tileSize) {
|
|
|
10279
10347
|
Math.floor(hexagonScaleFactor + latitudeScaleFactor - BIAS)
|
|
10280
10348
|
);
|
|
10281
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
|
+
}
|
|
10282
10407
|
// Annotate the CommonJS export names for ESM import in node:
|
|
10283
10408
|
0 && (module.exports = {
|
|
10409
|
+
AggregationTypes,
|
|
10284
10410
|
ApiVersion,
|
|
10285
10411
|
BASEMAP,
|
|
10286
10412
|
CartoAPIError,
|
|
10413
|
+
CellSet,
|
|
10287
10414
|
DEFAULT_API_BASE_URL,
|
|
10288
10415
|
FEATURE_GEOM_PROPERTY,
|
|
10289
10416
|
FilterType,
|