@carto/api-client 0.5.7-alpha.6 → 0.5.8-alpha-others-orderby.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -1
- package/build/api-client.cjs +482 -360
- package/build/api-client.cjs.map +1 -1
- package/build/api-client.d.cts +45 -17
- package/build/api-client.d.ts +45 -17
- package/build/api-client.js +467 -350
- package/build/api-client.js.map +1 -1
- package/build/worker-compat.js +769 -678
- package/build/worker-compat.js.map +1 -1
- package/build/worker.js +440 -346
- package/build/worker.js.map +1 -1
- package/package.json +2 -3
- package/src/filters/tileFeatures.ts +1 -1
- package/src/filters/tileFeaturesGeometries.ts +28 -55
- package/src/filters/tileFeaturesRaster.ts +10 -21
- package/src/filters/tileFeaturesSpatialIndex.ts +37 -50
- package/src/filters/tileIntersection.ts +155 -0
- package/src/operations/groupBy.ts +61 -12
- package/src/operations/groupByDate.ts +6 -1
- package/src/widget-sources/constants.ts +6 -0
- package/src/widget-sources/index.ts +1 -0
- package/src/widget-sources/types.ts +25 -1
- package/src/widget-sources/widget-remote-source.ts +28 -5
- package/src/widget-sources/widget-tileset-source-impl.ts +27 -6
package/build/api-client.cjs
CHANGED
|
@@ -108,6 +108,7 @@ __export(src_exports, {
|
|
|
108
108
|
FEATURE_GEOM_PROPERTY: () => FEATURE_GEOM_PROPERTY,
|
|
109
109
|
FilterType: () => FilterType,
|
|
110
110
|
OPACITY_MAP: () => OPACITY_MAP,
|
|
111
|
+
OTHERS_CATEGORY_NAME: () => OTHERS_CATEGORY_NAME,
|
|
111
112
|
Provider: () => Provider,
|
|
112
113
|
SOURCE_DEFAULTS: () => SOURCE_DEFAULTS,
|
|
113
114
|
SchemaFieldType: () => SchemaFieldType,
|
|
@@ -158,6 +159,7 @@ __export(src_exports, {
|
|
|
158
159
|
getLayerProps: () => getLayerProps,
|
|
159
160
|
getMaxMarkerSize: () => getMaxMarkerSize,
|
|
160
161
|
getSizeAccessor: () => getSizeAccessor,
|
|
162
|
+
getSorter: () => getSorter,
|
|
161
163
|
getSpatialIndexFromGeoColumn: () => getSpatialIndexFromGeoColumn,
|
|
162
164
|
getTextAccessor: () => getTextAccessor,
|
|
163
165
|
groupValuesByColumn: () => groupValuesByColumn,
|
|
@@ -1727,6 +1729,143 @@ init_cjs_shims();
|
|
|
1727
1729
|
// src/filters/tileFeaturesGeometries.ts
|
|
1728
1730
|
init_cjs_shims();
|
|
1729
1731
|
|
|
1732
|
+
// src/utils/transformTileCoordsToWGS84.ts
|
|
1733
|
+
init_cjs_shims();
|
|
1734
|
+
|
|
1735
|
+
// node_modules/@math.gl/core/dist/index.js
|
|
1736
|
+
init_cjs_shims();
|
|
1737
|
+
|
|
1738
|
+
// node_modules/@math.gl/core/dist/lib/common.js
|
|
1739
|
+
init_cjs_shims();
|
|
1740
|
+
var RADIANS_TO_DEGREES = 1 / Math.PI * 180;
|
|
1741
|
+
var DEGREES_TO_RADIANS = 1 / 180 * Math.PI;
|
|
1742
|
+
var DEFAULT_CONFIG = {
|
|
1743
|
+
EPSILON: 1e-12,
|
|
1744
|
+
debug: false,
|
|
1745
|
+
precision: 4,
|
|
1746
|
+
printTypes: false,
|
|
1747
|
+
printDegrees: false,
|
|
1748
|
+
printRowMajor: true,
|
|
1749
|
+
_cartographicRadians: false
|
|
1750
|
+
};
|
|
1751
|
+
globalThis.mathgl = globalThis.mathgl || { config: { ...DEFAULT_CONFIG } };
|
|
1752
|
+
var config = globalThis.mathgl.config;
|
|
1753
|
+
function isArray(value) {
|
|
1754
|
+
return Array.isArray(value) || ArrayBuffer.isView(value) && !(value instanceof DataView);
|
|
1755
|
+
}
|
|
1756
|
+
function lerp(a, b, t) {
|
|
1757
|
+
if (isArray(a)) {
|
|
1758
|
+
return a.map((ai, i) => lerp(ai, b[i], t));
|
|
1759
|
+
}
|
|
1760
|
+
return t * b + (1 - t) * a;
|
|
1761
|
+
}
|
|
1762
|
+
|
|
1763
|
+
// node_modules/@math.gl/web-mercator/dist/index.js
|
|
1764
|
+
init_cjs_shims();
|
|
1765
|
+
|
|
1766
|
+
// node_modules/@math.gl/web-mercator/dist/web-mercator-viewport.js
|
|
1767
|
+
init_cjs_shims();
|
|
1768
|
+
|
|
1769
|
+
// node_modules/@math.gl/web-mercator/dist/math-utils.js
|
|
1770
|
+
init_cjs_shims();
|
|
1771
|
+
|
|
1772
|
+
// node_modules/@math.gl/web-mercator/dist/web-mercator-utils.js
|
|
1773
|
+
init_cjs_shims();
|
|
1774
|
+
|
|
1775
|
+
// node_modules/@math.gl/web-mercator/dist/assert.js
|
|
1776
|
+
init_cjs_shims();
|
|
1777
|
+
function assert(condition, message) {
|
|
1778
|
+
if (!condition) {
|
|
1779
|
+
throw new Error(message || "@math.gl/web-mercator: assertion failed.");
|
|
1780
|
+
}
|
|
1781
|
+
}
|
|
1782
|
+
|
|
1783
|
+
// node_modules/@math.gl/web-mercator/dist/web-mercator-utils.js
|
|
1784
|
+
var PI = Math.PI;
|
|
1785
|
+
var PI_4 = PI / 4;
|
|
1786
|
+
var DEGREES_TO_RADIANS2 = PI / 180;
|
|
1787
|
+
var RADIANS_TO_DEGREES2 = 180 / PI;
|
|
1788
|
+
var TILE_SIZE = 512;
|
|
1789
|
+
function lngLatToWorld(lngLat) {
|
|
1790
|
+
const [lng, lat] = lngLat;
|
|
1791
|
+
assert(Number.isFinite(lng));
|
|
1792
|
+
assert(Number.isFinite(lat) && lat >= -90 && lat <= 90, "invalid latitude");
|
|
1793
|
+
const lambda2 = lng * DEGREES_TO_RADIANS2;
|
|
1794
|
+
const phi2 = lat * DEGREES_TO_RADIANS2;
|
|
1795
|
+
const x = TILE_SIZE * (lambda2 + PI) / (2 * PI);
|
|
1796
|
+
const y = TILE_SIZE * (PI + Math.log(Math.tan(PI_4 + phi2 * 0.5))) / (2 * PI);
|
|
1797
|
+
return [x, y];
|
|
1798
|
+
}
|
|
1799
|
+
function worldToLngLat(xy) {
|
|
1800
|
+
const [x, y] = xy;
|
|
1801
|
+
const lambda2 = x / TILE_SIZE * (2 * PI) - PI;
|
|
1802
|
+
const phi2 = 2 * (Math.atan(Math.exp(y / TILE_SIZE * (2 * PI) - PI)) - PI_4);
|
|
1803
|
+
return [lambda2 * RADIANS_TO_DEGREES2, phi2 * RADIANS_TO_DEGREES2];
|
|
1804
|
+
}
|
|
1805
|
+
|
|
1806
|
+
// node_modules/@math.gl/web-mercator/dist/fit-bounds.js
|
|
1807
|
+
init_cjs_shims();
|
|
1808
|
+
|
|
1809
|
+
// node_modules/@math.gl/web-mercator/dist/get-bounds.js
|
|
1810
|
+
init_cjs_shims();
|
|
1811
|
+
var DEGREES_TO_RADIANS3 = Math.PI / 180;
|
|
1812
|
+
|
|
1813
|
+
// node_modules/@math.gl/web-mercator/dist/normalize-viewport-props.js
|
|
1814
|
+
init_cjs_shims();
|
|
1815
|
+
|
|
1816
|
+
// node_modules/@math.gl/web-mercator/dist/fly-to-viewport.js
|
|
1817
|
+
init_cjs_shims();
|
|
1818
|
+
|
|
1819
|
+
// src/utils/transformTileCoordsToWGS84.ts
|
|
1820
|
+
var TRANSFORM_FN = {
|
|
1821
|
+
Point: transformPoint,
|
|
1822
|
+
MultiPoint: transformMultiPoint,
|
|
1823
|
+
LineString: transformLineString,
|
|
1824
|
+
MultiLineString: transformMultiLineString,
|
|
1825
|
+
Polygon: transformPolygon,
|
|
1826
|
+
MultiPolygon: transformMultiPolygon
|
|
1827
|
+
};
|
|
1828
|
+
function transformTileCoordsToWGS84(geometry, bbox2) {
|
|
1829
|
+
const [west, south, east, north] = bbox2;
|
|
1830
|
+
const nw = lngLatToWorld([west, north]);
|
|
1831
|
+
const se = lngLatToWorld([east, south]);
|
|
1832
|
+
const projectedBbox = [nw, se];
|
|
1833
|
+
if (geometry.type === "GeometryCollection") {
|
|
1834
|
+
throw new Error("Unsupported geometry type GeometryCollection");
|
|
1835
|
+
}
|
|
1836
|
+
const transformFn = TRANSFORM_FN[geometry.type];
|
|
1837
|
+
const coordinates = transformFn(geometry.coordinates, projectedBbox);
|
|
1838
|
+
return { ...geometry, coordinates };
|
|
1839
|
+
}
|
|
1840
|
+
function transformPoint([pointX, pointY], [nw, se]) {
|
|
1841
|
+
const x = lerp(nw[0], se[0], pointX);
|
|
1842
|
+
const y = lerp(nw[1], se[1], pointY);
|
|
1843
|
+
return worldToLngLat([x, y]);
|
|
1844
|
+
}
|
|
1845
|
+
function getPoints(geometry, bbox2) {
|
|
1846
|
+
return geometry.map((g) => transformPoint(g, bbox2));
|
|
1847
|
+
}
|
|
1848
|
+
function transformMultiPoint(multiPoint, bbox2) {
|
|
1849
|
+
return getPoints(multiPoint, bbox2);
|
|
1850
|
+
}
|
|
1851
|
+
function transformLineString(line, bbox2) {
|
|
1852
|
+
return getPoints(line, bbox2);
|
|
1853
|
+
}
|
|
1854
|
+
function transformMultiLineString(multiLineString2, bbox2) {
|
|
1855
|
+
return multiLineString2.map(
|
|
1856
|
+
(lineString2) => transformLineString(lineString2, bbox2)
|
|
1857
|
+
);
|
|
1858
|
+
}
|
|
1859
|
+
function transformPolygon(polygon2, bbox2) {
|
|
1860
|
+
return polygon2.map((polygonRing) => getPoints(polygonRing, bbox2));
|
|
1861
|
+
}
|
|
1862
|
+
function transformMultiPolygon(multiPolygon2, bbox2) {
|
|
1863
|
+
return multiPolygon2.map((polygon2) => transformPolygon(polygon2, bbox2));
|
|
1864
|
+
}
|
|
1865
|
+
|
|
1866
|
+
// src/filters/tileIntersection.ts
|
|
1867
|
+
init_cjs_shims();
|
|
1868
|
+
|
|
1730
1869
|
// node_modules/@turf/bbox-polygon/dist/esm/index.js
|
|
1731
1870
|
init_cjs_shims();
|
|
1732
1871
|
function bboxPolygon(bbox2, options = {}) {
|
|
@@ -2058,7 +2197,7 @@ var MAX_SAFE_INTEGER = 9007199254740991;
|
|
|
2058
2197
|
var POWS_TEN = [1, 10, 100, 1e3, 1e4, 1e5, 1e6, 1e7, 1e8, 1e9, 1e10, 1e11, 1e12, 1e13];
|
|
2059
2198
|
var SQRT_BASE = 1e7;
|
|
2060
2199
|
var MAX = 1e9;
|
|
2061
|
-
function
|
|
2200
|
+
function clone2(configObject) {
|
|
2062
2201
|
var div, convertBase, parseNumeric, P = BigNumber2.prototype = { constructor: BigNumber2, toString: null, valueOf: null }, ONE = new BigNumber2(1), DECIMAL_PLACES = 20, ROUNDING_MODE = 4, TO_EXP_NEG = -7, TO_EXP_POS = 21, MIN_EXP = -1e7, MAX_EXP = 1e7, CRYPTO = false, MODULO_MODE = 1, POW_PRECISION = 0, FORMAT = {
|
|
2063
2202
|
prefix: "",
|
|
2064
2203
|
groupSize: 3,
|
|
@@ -2184,7 +2323,7 @@ function clone(configObject) {
|
|
|
2184
2323
|
x.c = [x.e = 0];
|
|
2185
2324
|
}
|
|
2186
2325
|
}
|
|
2187
|
-
BigNumber2.clone =
|
|
2326
|
+
BigNumber2.clone = clone2;
|
|
2188
2327
|
BigNumber2.ROUND_UP = 0;
|
|
2189
2328
|
BigNumber2.ROUND_DOWN = 1;
|
|
2190
2329
|
BigNumber2.ROUND_CEIL = 2;
|
|
@@ -3387,7 +3526,7 @@ function toFixedPoint(str, e, z) {
|
|
|
3387
3526
|
}
|
|
3388
3527
|
return str;
|
|
3389
3528
|
}
|
|
3390
|
-
var BigNumber =
|
|
3529
|
+
var BigNumber = clone2();
|
|
3391
3530
|
var bignumber_default = BigNumber;
|
|
3392
3531
|
|
|
3393
3532
|
// node_modules/splaytree-ts/dist/esm/index.js
|
|
@@ -4960,99 +5099,13 @@ var turf_intersect_default = intersect;
|
|
|
4960
5099
|
|
|
4961
5100
|
// src/utils/transformToTileCoords.ts
|
|
4962
5101
|
init_cjs_shims();
|
|
4963
|
-
|
|
4964
|
-
|
|
4965
|
-
|
|
4966
|
-
|
|
4967
|
-
|
|
4968
|
-
|
|
4969
|
-
|
|
4970
|
-
// node_modules/@math.gl/web-mercator/dist/math-utils.js
|
|
4971
|
-
init_cjs_shims();
|
|
4972
|
-
|
|
4973
|
-
// node_modules/@math.gl/core/dist/index.js
|
|
4974
|
-
init_cjs_shims();
|
|
4975
|
-
|
|
4976
|
-
// node_modules/@math.gl/core/dist/lib/common.js
|
|
4977
|
-
init_cjs_shims();
|
|
4978
|
-
var RADIANS_TO_DEGREES = 1 / Math.PI * 180;
|
|
4979
|
-
var DEGREES_TO_RADIANS = 1 / 180 * Math.PI;
|
|
4980
|
-
var DEFAULT_CONFIG = {
|
|
4981
|
-
EPSILON: 1e-12,
|
|
4982
|
-
debug: false,
|
|
4983
|
-
precision: 4,
|
|
4984
|
-
printTypes: false,
|
|
4985
|
-
printDegrees: false,
|
|
4986
|
-
printRowMajor: true,
|
|
4987
|
-
_cartographicRadians: false
|
|
4988
|
-
};
|
|
4989
|
-
globalThis.mathgl = globalThis.mathgl || { config: { ...DEFAULT_CONFIG } };
|
|
4990
|
-
var config = globalThis.mathgl.config;
|
|
4991
|
-
function isArray(value) {
|
|
4992
|
-
return Array.isArray(value) || ArrayBuffer.isView(value) && !(value instanceof DataView);
|
|
4993
|
-
}
|
|
4994
|
-
function lerp(a, b, t) {
|
|
4995
|
-
if (isArray(a)) {
|
|
4996
|
-
return a.map((ai, i) => lerp(ai, b[i], t));
|
|
4997
|
-
}
|
|
4998
|
-
return t * b + (1 - t) * a;
|
|
4999
|
-
}
|
|
5000
|
-
|
|
5001
|
-
// node_modules/@math.gl/web-mercator/dist/web-mercator-utils.js
|
|
5002
|
-
init_cjs_shims();
|
|
5003
|
-
|
|
5004
|
-
// node_modules/@math.gl/web-mercator/dist/assert.js
|
|
5005
|
-
init_cjs_shims();
|
|
5006
|
-
function assert(condition, message) {
|
|
5007
|
-
if (!condition) {
|
|
5008
|
-
throw new Error(message || "@math.gl/web-mercator: assertion failed.");
|
|
5009
|
-
}
|
|
5010
|
-
}
|
|
5011
|
-
|
|
5012
|
-
// node_modules/@math.gl/web-mercator/dist/web-mercator-utils.js
|
|
5013
|
-
var PI = Math.PI;
|
|
5014
|
-
var PI_4 = PI / 4;
|
|
5015
|
-
var DEGREES_TO_RADIANS2 = PI / 180;
|
|
5016
|
-
var RADIANS_TO_DEGREES2 = 180 / PI;
|
|
5017
|
-
var TILE_SIZE = 512;
|
|
5018
|
-
function lngLatToWorld(lngLat) {
|
|
5019
|
-
const [lng, lat] = lngLat;
|
|
5020
|
-
assert(Number.isFinite(lng));
|
|
5021
|
-
assert(Number.isFinite(lat) && lat >= -90 && lat <= 90, "invalid latitude");
|
|
5022
|
-
const lambda2 = lng * DEGREES_TO_RADIANS2;
|
|
5023
|
-
const phi2 = lat * DEGREES_TO_RADIANS2;
|
|
5024
|
-
const x = TILE_SIZE * (lambda2 + PI) / (2 * PI);
|
|
5025
|
-
const y = TILE_SIZE * (PI + Math.log(Math.tan(PI_4 + phi2 * 0.5))) / (2 * PI);
|
|
5026
|
-
return [x, y];
|
|
5027
|
-
}
|
|
5028
|
-
function worldToLngLat(xy) {
|
|
5029
|
-
const [x, y] = xy;
|
|
5030
|
-
const lambda2 = x / TILE_SIZE * (2 * PI) - PI;
|
|
5031
|
-
const phi2 = 2 * (Math.atan(Math.exp(y / TILE_SIZE * (2 * PI) - PI)) - PI_4);
|
|
5032
|
-
return [lambda2 * RADIANS_TO_DEGREES2, phi2 * RADIANS_TO_DEGREES2];
|
|
5033
|
-
}
|
|
5034
|
-
|
|
5035
|
-
// node_modules/@math.gl/web-mercator/dist/fit-bounds.js
|
|
5036
|
-
init_cjs_shims();
|
|
5037
|
-
|
|
5038
|
-
// node_modules/@math.gl/web-mercator/dist/get-bounds.js
|
|
5039
|
-
init_cjs_shims();
|
|
5040
|
-
var DEGREES_TO_RADIANS3 = Math.PI / 180;
|
|
5041
|
-
|
|
5042
|
-
// node_modules/@math.gl/web-mercator/dist/normalize-viewport-props.js
|
|
5043
|
-
init_cjs_shims();
|
|
5044
|
-
|
|
5045
|
-
// node_modules/@math.gl/web-mercator/dist/fly-to-viewport.js
|
|
5046
|
-
init_cjs_shims();
|
|
5047
|
-
|
|
5048
|
-
// src/utils/transformToTileCoords.ts
|
|
5049
|
-
var TRANSFORM_FN = {
|
|
5050
|
-
Point: transformPoint,
|
|
5051
|
-
MultiPoint: transformMultiPoint,
|
|
5052
|
-
LineString: transformLineString,
|
|
5053
|
-
MultiLineString: transformMultiLineString,
|
|
5054
|
-
Polygon: transformPolygon,
|
|
5055
|
-
MultiPolygon: transformMultiPolygon
|
|
5102
|
+
var TRANSFORM_FN2 = {
|
|
5103
|
+
Point: transformPoint2,
|
|
5104
|
+
MultiPoint: transformMultiPoint2,
|
|
5105
|
+
LineString: transformLineString2,
|
|
5106
|
+
MultiLineString: transformMultiLineString2,
|
|
5107
|
+
Polygon: transformPolygon2,
|
|
5108
|
+
MultiPolygon: transformMultiPolygon2
|
|
5056
5109
|
};
|
|
5057
5110
|
function transformToTileCoords(geometry, bbox2) {
|
|
5058
5111
|
const [west, south, east, north] = bbox2;
|
|
@@ -5062,34 +5115,34 @@ function transformToTileCoords(geometry, bbox2) {
|
|
|
5062
5115
|
if (geometry.type === "GeometryCollection") {
|
|
5063
5116
|
throw new Error("Unsupported geometry type GeometryCollection");
|
|
5064
5117
|
}
|
|
5065
|
-
const transformFn =
|
|
5118
|
+
const transformFn = TRANSFORM_FN2[geometry.type];
|
|
5066
5119
|
const coordinates = transformFn(geometry.coordinates, projectedBbox);
|
|
5067
5120
|
return { ...geometry, coordinates };
|
|
5068
5121
|
}
|
|
5069
|
-
function
|
|
5122
|
+
function transformPoint2([pointX, pointY], [nw, se]) {
|
|
5070
5123
|
const x = inverseLerp(nw[0], se[0], pointX);
|
|
5071
5124
|
const y = inverseLerp(nw[1], se[1], pointY);
|
|
5072
5125
|
return [x, y];
|
|
5073
5126
|
}
|
|
5074
|
-
function
|
|
5075
|
-
return geometry.map((g) =>
|
|
5127
|
+
function getPoints2(geometry, bbox2) {
|
|
5128
|
+
return geometry.map((g) => transformPoint2(projectFlat(g), bbox2));
|
|
5076
5129
|
}
|
|
5077
|
-
function
|
|
5078
|
-
return
|
|
5130
|
+
function transformMultiPoint2(multiPoint, bbox2) {
|
|
5131
|
+
return getPoints2(multiPoint, bbox2);
|
|
5079
5132
|
}
|
|
5080
|
-
function
|
|
5081
|
-
return
|
|
5133
|
+
function transformLineString2(line, bbox2) {
|
|
5134
|
+
return getPoints2(line, bbox2);
|
|
5082
5135
|
}
|
|
5083
|
-
function
|
|
5136
|
+
function transformMultiLineString2(multiLineString2, bbox2) {
|
|
5084
5137
|
return multiLineString2.map(
|
|
5085
|
-
(lineString2) =>
|
|
5138
|
+
(lineString2) => transformLineString2(lineString2, bbox2)
|
|
5086
5139
|
);
|
|
5087
5140
|
}
|
|
5088
|
-
function
|
|
5089
|
-
return polygon2.map((polygonRing) =>
|
|
5090
|
-
}
|
|
5091
|
-
function
|
|
5092
|
-
return multiPolygon2.map((polygon2) =>
|
|
5141
|
+
function transformPolygon2(polygon2, bbox2) {
|
|
5142
|
+
return polygon2.map((polygonRing) => getPoints2(polygonRing, bbox2));
|
|
5143
|
+
}
|
|
5144
|
+
function transformMultiPolygon2(multiPolygon2, bbox2) {
|
|
5145
|
+
return multiPolygon2.map((polygon2) => transformPolygon2(polygon2, bbox2));
|
|
5093
5146
|
}
|
|
5094
5147
|
function projectFlat(xyz) {
|
|
5095
5148
|
return lngLatToWorld(xyz);
|
|
@@ -5098,52 +5151,181 @@ function inverseLerp(a, b, x) {
|
|
|
5098
5151
|
return (x - a) / (b - a);
|
|
5099
5152
|
}
|
|
5100
5153
|
|
|
5101
|
-
// src/
|
|
5154
|
+
// src/filters/tileIntersection.ts
|
|
5155
|
+
var import_quadbin = require("quadbin");
|
|
5156
|
+
var import_h3_js = require("h3-js");
|
|
5157
|
+
|
|
5158
|
+
// node_modules/@turf/bbox-clip/dist/esm/index.js
|
|
5102
5159
|
init_cjs_shims();
|
|
5103
|
-
|
|
5104
|
-
|
|
5105
|
-
|
|
5106
|
-
|
|
5107
|
-
|
|
5108
|
-
|
|
5109
|
-
|
|
5110
|
-
|
|
5111
|
-
|
|
5112
|
-
|
|
5113
|
-
|
|
5114
|
-
|
|
5115
|
-
|
|
5116
|
-
|
|
5117
|
-
|
|
5160
|
+
function lineclip(points, bbox2, result) {
|
|
5161
|
+
var len = points.length, codeA = bitCode(points[0], bbox2), part = [], i, codeB, lastCode;
|
|
5162
|
+
let a;
|
|
5163
|
+
let b;
|
|
5164
|
+
if (!result) result = [];
|
|
5165
|
+
for (i = 1; i < len; i++) {
|
|
5166
|
+
a = points[i - 1];
|
|
5167
|
+
b = points[i];
|
|
5168
|
+
codeB = lastCode = bitCode(b, bbox2);
|
|
5169
|
+
while (true) {
|
|
5170
|
+
if (!(codeA | codeB)) {
|
|
5171
|
+
part.push(a);
|
|
5172
|
+
if (codeB !== lastCode) {
|
|
5173
|
+
part.push(b);
|
|
5174
|
+
if (i < len - 1) {
|
|
5175
|
+
result.push(part);
|
|
5176
|
+
part = [];
|
|
5177
|
+
}
|
|
5178
|
+
} else if (i === len - 1) {
|
|
5179
|
+
part.push(b);
|
|
5180
|
+
}
|
|
5181
|
+
break;
|
|
5182
|
+
} else if (codeA & codeB) {
|
|
5183
|
+
break;
|
|
5184
|
+
} else if (codeA) {
|
|
5185
|
+
a = intersect2(a, b, codeA, bbox2);
|
|
5186
|
+
codeA = bitCode(a, bbox2);
|
|
5187
|
+
} else {
|
|
5188
|
+
b = intersect2(a, b, codeB, bbox2);
|
|
5189
|
+
codeB = bitCode(b, bbox2);
|
|
5190
|
+
}
|
|
5191
|
+
}
|
|
5192
|
+
codeA = lastCode;
|
|
5118
5193
|
}
|
|
5119
|
-
|
|
5120
|
-
|
|
5121
|
-
return { ...geometry, coordinates };
|
|
5194
|
+
if (part.length) result.push(part);
|
|
5195
|
+
return result;
|
|
5122
5196
|
}
|
|
5123
|
-
function
|
|
5124
|
-
|
|
5125
|
-
|
|
5126
|
-
|
|
5197
|
+
function polygonclip(points, bbox2) {
|
|
5198
|
+
var result, edge, prev, prevInside, i, p, inside;
|
|
5199
|
+
for (edge = 1; edge <= 8; edge *= 2) {
|
|
5200
|
+
result = [];
|
|
5201
|
+
prev = points[points.length - 1];
|
|
5202
|
+
prevInside = !(bitCode(prev, bbox2) & edge);
|
|
5203
|
+
for (i = 0; i < points.length; i++) {
|
|
5204
|
+
p = points[i];
|
|
5205
|
+
inside = !(bitCode(p, bbox2) & edge);
|
|
5206
|
+
if (inside !== prevInside) result.push(intersect2(prev, p, edge, bbox2));
|
|
5207
|
+
if (inside) result.push(p);
|
|
5208
|
+
prev = p;
|
|
5209
|
+
prevInside = inside;
|
|
5210
|
+
}
|
|
5211
|
+
points = result;
|
|
5212
|
+
if (!points.length) break;
|
|
5213
|
+
}
|
|
5214
|
+
return result;
|
|
5127
5215
|
}
|
|
5128
|
-
function
|
|
5129
|
-
return
|
|
5216
|
+
function intersect2(a, b, edge, bbox2) {
|
|
5217
|
+
return edge & 8 ? [a[0] + (b[0] - a[0]) * (bbox2[3] - a[1]) / (b[1] - a[1]), bbox2[3]] : edge & 4 ? [a[0] + (b[0] - a[0]) * (bbox2[1] - a[1]) / (b[1] - a[1]), bbox2[1]] : edge & 2 ? [bbox2[2], a[1] + (b[1] - a[1]) * (bbox2[2] - a[0]) / (b[0] - a[0])] : edge & 1 ? [bbox2[0], a[1] + (b[1] - a[1]) * (bbox2[0] - a[0]) / (b[0] - a[0])] : null;
|
|
5130
5218
|
}
|
|
5131
|
-
function
|
|
5132
|
-
|
|
5219
|
+
function bitCode(p, bbox2) {
|
|
5220
|
+
var code = 0;
|
|
5221
|
+
if (p[0] < bbox2[0]) code |= 1;
|
|
5222
|
+
else if (p[0] > bbox2[2]) code |= 2;
|
|
5223
|
+
if (p[1] < bbox2[1]) code |= 4;
|
|
5224
|
+
else if (p[1] > bbox2[3]) code |= 8;
|
|
5225
|
+
return code;
|
|
5133
5226
|
}
|
|
5134
|
-
function
|
|
5135
|
-
|
|
5227
|
+
function bboxClip(feature2, bbox2) {
|
|
5228
|
+
const geom = getGeom(feature2);
|
|
5229
|
+
const type = geom.type;
|
|
5230
|
+
const properties = feature2.type === "Feature" ? feature2.properties : {};
|
|
5231
|
+
let coords = geom.coordinates;
|
|
5232
|
+
switch (type) {
|
|
5233
|
+
case "LineString":
|
|
5234
|
+
case "MultiLineString": {
|
|
5235
|
+
const lines = [];
|
|
5236
|
+
if (type === "LineString") {
|
|
5237
|
+
coords = [coords];
|
|
5238
|
+
}
|
|
5239
|
+
coords.forEach((line) => {
|
|
5240
|
+
lineclip(line, bbox2, lines);
|
|
5241
|
+
});
|
|
5242
|
+
if (lines.length === 1) {
|
|
5243
|
+
return lineString(lines[0], properties);
|
|
5244
|
+
}
|
|
5245
|
+
return multiLineString(lines, properties);
|
|
5246
|
+
}
|
|
5247
|
+
case "Polygon":
|
|
5248
|
+
return polygon(clipPolygon(coords, bbox2), properties);
|
|
5249
|
+
case "MultiPolygon":
|
|
5250
|
+
return multiPolygon(
|
|
5251
|
+
coords.map((poly) => {
|
|
5252
|
+
return clipPolygon(poly, bbox2);
|
|
5253
|
+
}),
|
|
5254
|
+
properties
|
|
5255
|
+
);
|
|
5256
|
+
default:
|
|
5257
|
+
throw new Error("geometry " + type + " not supported");
|
|
5258
|
+
}
|
|
5136
5259
|
}
|
|
5137
|
-
function
|
|
5138
|
-
|
|
5139
|
-
|
|
5260
|
+
function clipPolygon(rings, bbox2) {
|
|
5261
|
+
const outRings = [];
|
|
5262
|
+
for (const ring of rings) {
|
|
5263
|
+
const clipped = polygonclip(ring, bbox2);
|
|
5264
|
+
if (clipped.length > 0) {
|
|
5265
|
+
if (clipped[0][0] !== clipped[clipped.length - 1][0] || clipped[0][1] !== clipped[clipped.length - 1][1]) {
|
|
5266
|
+
clipped.push(clipped[0]);
|
|
5267
|
+
}
|
|
5268
|
+
if (clipped.length >= 4) {
|
|
5269
|
+
outRings.push(clipped);
|
|
5270
|
+
}
|
|
5271
|
+
}
|
|
5272
|
+
}
|
|
5273
|
+
return outRings;
|
|
5274
|
+
}
|
|
5275
|
+
var turf_bbox_clip_default = bboxClip;
|
|
5276
|
+
|
|
5277
|
+
// src/filters/tileIntersection.ts
|
|
5278
|
+
function intersectTileGeometry(tileBbox, tileFormat, spatialFilter) {
|
|
5279
|
+
const tilePolygon = turf_bbox_polygon_default(tileBbox);
|
|
5280
|
+
if (!spatialFilter || turf_boolean_within_default(tilePolygon, spatialFilter)) {
|
|
5281
|
+
return true;
|
|
5282
|
+
}
|
|
5283
|
+
const clippedSpatialFilter = turf_intersect_default(
|
|
5284
|
+
featureCollection([tilePolygon, feature(spatialFilter)])
|
|
5140
5285
|
);
|
|
5286
|
+
if (!clippedSpatialFilter) {
|
|
5287
|
+
return false;
|
|
5288
|
+
}
|
|
5289
|
+
return tileFormat === "mvt" /* MVT */ ? transformToTileCoords(clippedSpatialFilter.geometry, tileBbox) : clippedSpatialFilter.geometry;
|
|
5141
5290
|
}
|
|
5142
|
-
function
|
|
5143
|
-
return
|
|
5291
|
+
function intersectTileRaster(parent, cellResolution, spatialFilter) {
|
|
5292
|
+
return intersectTileQuadbin(parent, cellResolution, spatialFilter);
|
|
5144
5293
|
}
|
|
5145
|
-
function
|
|
5146
|
-
|
|
5294
|
+
function intersectTileQuadbin(parent, cellResolution, spatialFilter) {
|
|
5295
|
+
const tilePolygon = (0, import_quadbin.cellToBoundary)(parent);
|
|
5296
|
+
if (!spatialFilter || turf_boolean_within_default(tilePolygon, spatialFilter)) {
|
|
5297
|
+
return true;
|
|
5298
|
+
}
|
|
5299
|
+
const clippedSpatialFilter = turf_intersect_default(
|
|
5300
|
+
featureCollection([feature(tilePolygon), feature(spatialFilter)])
|
|
5301
|
+
);
|
|
5302
|
+
if (!clippedSpatialFilter) {
|
|
5303
|
+
return false;
|
|
5304
|
+
}
|
|
5305
|
+
const cells = (0, import_quadbin.geometryToCells)(
|
|
5306
|
+
clippedSpatialFilter.geometry,
|
|
5307
|
+
cellResolution
|
|
5308
|
+
);
|
|
5309
|
+
return new Set(cells);
|
|
5310
|
+
}
|
|
5311
|
+
var BBOX_WEST = [-180, -90, 0, 90];
|
|
5312
|
+
var BBOX_EAST = [0, -90, 180, 90];
|
|
5313
|
+
function intersectTileH3(cellResolution, spatialFilter) {
|
|
5314
|
+
if (!spatialFilter) {
|
|
5315
|
+
return true;
|
|
5316
|
+
}
|
|
5317
|
+
const spatialFilterFeature = feature(spatialFilter);
|
|
5318
|
+
const cellsWest = (0, import_h3_js.polygonToCells)(
|
|
5319
|
+
turf_bbox_clip_default(spatialFilterFeature, BBOX_WEST).geometry.coordinates,
|
|
5320
|
+
cellResolution,
|
|
5321
|
+
true
|
|
5322
|
+
);
|
|
5323
|
+
const cellsEast = (0, import_h3_js.polygonToCells)(
|
|
5324
|
+
turf_bbox_clip_default(spatialFilterFeature, BBOX_EAST).geometry.coordinates,
|
|
5325
|
+
cellResolution,
|
|
5326
|
+
true
|
|
5327
|
+
);
|
|
5328
|
+
return new Set(cellsWest.concat(cellsEast));
|
|
5147
5329
|
}
|
|
5148
5330
|
|
|
5149
5331
|
// src/filters/tileFeaturesGeometries.ts
|
|
@@ -5160,55 +5342,45 @@ function tileFeaturesGeometries({
|
|
|
5160
5342
|
if (tile.isVisible === false || !tile.data) {
|
|
5161
5343
|
continue;
|
|
5162
5344
|
}
|
|
5163
|
-
const
|
|
5345
|
+
const tileBbox = [
|
|
5164
5346
|
tile.bbox.west,
|
|
5165
5347
|
tile.bbox.south,
|
|
5166
5348
|
tile.bbox.east,
|
|
5167
5349
|
tile.bbox.north
|
|
5168
5350
|
];
|
|
5169
|
-
const
|
|
5170
|
-
|
|
5171
|
-
|
|
5172
|
-
|
|
5173
|
-
geometry: spatialFilter,
|
|
5174
|
-
properties: {}
|
|
5175
|
-
};
|
|
5176
|
-
const clippedGeometryToIntersect = turf_intersect_default(
|
|
5177
|
-
featureCollection([bboxToGeom, spatialFilterFeature])
|
|
5351
|
+
const intersection3 = intersectTileGeometry(
|
|
5352
|
+
tileBbox,
|
|
5353
|
+
tileFormat,
|
|
5354
|
+
spatialFilter
|
|
5178
5355
|
);
|
|
5179
|
-
if (
|
|
5180
|
-
|
|
5181
|
-
}
|
|
5182
|
-
const transformedGeometryToIntersect = tileFormat === "mvt" /* MVT */ ? transformToTileCoords(clippedGeometryToIntersect.geometry, bbox2) : clippedGeometryToIntersect.geometry;
|
|
5356
|
+
if (intersection3 === false) continue;
|
|
5357
|
+
const transformedSpatialFilter = intersection3 === true ? void 0 : intersection3;
|
|
5183
5358
|
calculateFeatures({
|
|
5184
5359
|
map,
|
|
5185
|
-
|
|
5186
|
-
geometryIntersection: transformedGeometryToIntersect,
|
|
5360
|
+
spatialFilter: transformedSpatialFilter,
|
|
5187
5361
|
data: tile.data.points,
|
|
5188
5362
|
type: "Point",
|
|
5189
|
-
bbox:
|
|
5363
|
+
bbox: tileBbox,
|
|
5190
5364
|
tileFormat,
|
|
5191
5365
|
uniqueIdProperty,
|
|
5192
5366
|
options
|
|
5193
5367
|
});
|
|
5194
5368
|
calculateFeatures({
|
|
5195
5369
|
map,
|
|
5196
|
-
|
|
5197
|
-
geometryIntersection: transformedGeometryToIntersect,
|
|
5370
|
+
spatialFilter: transformedSpatialFilter,
|
|
5198
5371
|
data: tile.data.lines,
|
|
5199
5372
|
type: "LineString",
|
|
5200
|
-
bbox:
|
|
5373
|
+
bbox: tileBbox,
|
|
5201
5374
|
tileFormat,
|
|
5202
5375
|
uniqueIdProperty,
|
|
5203
5376
|
options
|
|
5204
5377
|
});
|
|
5205
5378
|
calculateFeatures({
|
|
5206
5379
|
map,
|
|
5207
|
-
|
|
5208
|
-
geometryIntersection: transformedGeometryToIntersect,
|
|
5380
|
+
spatialFilter: transformedSpatialFilter,
|
|
5209
5381
|
data: tile.data.polygons,
|
|
5210
5382
|
type: "Polygon",
|
|
5211
|
-
bbox:
|
|
5383
|
+
bbox: tileBbox,
|
|
5212
5384
|
tileFormat,
|
|
5213
5385
|
uniqueIdProperty,
|
|
5214
5386
|
options
|
|
@@ -5226,7 +5398,7 @@ function processTileFeatureProperties({
|
|
|
5226
5398
|
tileFormat,
|
|
5227
5399
|
uniqueIdProperty,
|
|
5228
5400
|
storeGeometry,
|
|
5229
|
-
|
|
5401
|
+
spatialFilter
|
|
5230
5402
|
}) {
|
|
5231
5403
|
const tileProps = getPropertiesFromTile(data, startIndex);
|
|
5232
5404
|
const uniquePropertyValue = getUniquePropertyValue(
|
|
@@ -5238,7 +5410,7 @@ function processTileFeatureProperties({
|
|
|
5238
5410
|
return;
|
|
5239
5411
|
}
|
|
5240
5412
|
let geometry = null;
|
|
5241
|
-
if (storeGeometry ||
|
|
5413
|
+
if (storeGeometry || spatialFilter) {
|
|
5242
5414
|
const { positions } = data;
|
|
5243
5415
|
const ringCoordinates = getRingCoordinatesFor(
|
|
5244
5416
|
startIndex,
|
|
@@ -5247,7 +5419,7 @@ function processTileFeatureProperties({
|
|
|
5247
5419
|
);
|
|
5248
5420
|
geometry = getFeatureByType(ringCoordinates, type);
|
|
5249
5421
|
}
|
|
5250
|
-
if (geometry &&
|
|
5422
|
+
if (geometry && spatialFilter && !turf_boolean_intersects_default(geometry, spatialFilter)) {
|
|
5251
5423
|
return;
|
|
5252
5424
|
}
|
|
5253
5425
|
const properties = parseProperties(tileProps);
|
|
@@ -5259,7 +5431,7 @@ function processTileFeatureProperties({
|
|
|
5259
5431
|
function addIntersectedFeaturesInTile({
|
|
5260
5432
|
map,
|
|
5261
5433
|
data,
|
|
5262
|
-
|
|
5434
|
+
spatialFilter,
|
|
5263
5435
|
type,
|
|
5264
5436
|
bbox: bbox2,
|
|
5265
5437
|
tileFormat,
|
|
@@ -5281,7 +5453,7 @@ function addIntersectedFeaturesInTile({
|
|
|
5281
5453
|
tileFormat,
|
|
5282
5454
|
uniqueIdProperty,
|
|
5283
5455
|
storeGeometry,
|
|
5284
|
-
|
|
5456
|
+
spatialFilter
|
|
5285
5457
|
});
|
|
5286
5458
|
}
|
|
5287
5459
|
}
|
|
@@ -5363,8 +5535,7 @@ function getRingCoordinatesFor(startIndex, endIndex, positions) {
|
|
|
5363
5535
|
}
|
|
5364
5536
|
function calculateFeatures({
|
|
5365
5537
|
map,
|
|
5366
|
-
|
|
5367
|
-
geometryIntersection,
|
|
5538
|
+
spatialFilter,
|
|
5368
5539
|
data,
|
|
5369
5540
|
type,
|
|
5370
5541
|
bbox: bbox2,
|
|
@@ -5375,7 +5546,7 @@ function calculateFeatures({
|
|
|
5375
5546
|
if (!data?.properties.length) {
|
|
5376
5547
|
return;
|
|
5377
5548
|
}
|
|
5378
|
-
if (
|
|
5549
|
+
if (!spatialFilter) {
|
|
5379
5550
|
addAllFeaturesInTile({
|
|
5380
5551
|
map,
|
|
5381
5552
|
data,
|
|
@@ -5389,7 +5560,7 @@ function calculateFeatures({
|
|
|
5389
5560
|
addIntersectedFeaturesInTile({
|
|
5390
5561
|
map,
|
|
5391
5562
|
data,
|
|
5392
|
-
|
|
5563
|
+
spatialFilter,
|
|
5393
5564
|
type,
|
|
5394
5565
|
bbox: bbox2,
|
|
5395
5566
|
tileFormat,
|
|
@@ -5440,129 +5611,8 @@ function createIndicesForPoints(data) {
|
|
|
5440
5611
|
|
|
5441
5612
|
// src/filters/tileFeaturesSpatialIndex.ts
|
|
5442
5613
|
init_cjs_shims();
|
|
5443
|
-
var
|
|
5444
|
-
|
|
5445
|
-
// node_modules/@turf/bbox-clip/dist/esm/index.js
|
|
5446
|
-
init_cjs_shims();
|
|
5447
|
-
function lineclip(points, bbox2, result) {
|
|
5448
|
-
var len = points.length, codeA = bitCode(points[0], bbox2), part = [], i, codeB, lastCode;
|
|
5449
|
-
let a;
|
|
5450
|
-
let b;
|
|
5451
|
-
if (!result) result = [];
|
|
5452
|
-
for (i = 1; i < len; i++) {
|
|
5453
|
-
a = points[i - 1];
|
|
5454
|
-
b = points[i];
|
|
5455
|
-
codeB = lastCode = bitCode(b, bbox2);
|
|
5456
|
-
while (true) {
|
|
5457
|
-
if (!(codeA | codeB)) {
|
|
5458
|
-
part.push(a);
|
|
5459
|
-
if (codeB !== lastCode) {
|
|
5460
|
-
part.push(b);
|
|
5461
|
-
if (i < len - 1) {
|
|
5462
|
-
result.push(part);
|
|
5463
|
-
part = [];
|
|
5464
|
-
}
|
|
5465
|
-
} else if (i === len - 1) {
|
|
5466
|
-
part.push(b);
|
|
5467
|
-
}
|
|
5468
|
-
break;
|
|
5469
|
-
} else if (codeA & codeB) {
|
|
5470
|
-
break;
|
|
5471
|
-
} else if (codeA) {
|
|
5472
|
-
a = intersect2(a, b, codeA, bbox2);
|
|
5473
|
-
codeA = bitCode(a, bbox2);
|
|
5474
|
-
} else {
|
|
5475
|
-
b = intersect2(a, b, codeB, bbox2);
|
|
5476
|
-
codeB = bitCode(b, bbox2);
|
|
5477
|
-
}
|
|
5478
|
-
}
|
|
5479
|
-
codeA = lastCode;
|
|
5480
|
-
}
|
|
5481
|
-
if (part.length) result.push(part);
|
|
5482
|
-
return result;
|
|
5483
|
-
}
|
|
5484
|
-
function polygonclip(points, bbox2) {
|
|
5485
|
-
var result, edge, prev, prevInside, i, p, inside;
|
|
5486
|
-
for (edge = 1; edge <= 8; edge *= 2) {
|
|
5487
|
-
result = [];
|
|
5488
|
-
prev = points[points.length - 1];
|
|
5489
|
-
prevInside = !(bitCode(prev, bbox2) & edge);
|
|
5490
|
-
for (i = 0; i < points.length; i++) {
|
|
5491
|
-
p = points[i];
|
|
5492
|
-
inside = !(bitCode(p, bbox2) & edge);
|
|
5493
|
-
if (inside !== prevInside) result.push(intersect2(prev, p, edge, bbox2));
|
|
5494
|
-
if (inside) result.push(p);
|
|
5495
|
-
prev = p;
|
|
5496
|
-
prevInside = inside;
|
|
5497
|
-
}
|
|
5498
|
-
points = result;
|
|
5499
|
-
if (!points.length) break;
|
|
5500
|
-
}
|
|
5501
|
-
return result;
|
|
5502
|
-
}
|
|
5503
|
-
function intersect2(a, b, edge, bbox2) {
|
|
5504
|
-
return edge & 8 ? [a[0] + (b[0] - a[0]) * (bbox2[3] - a[1]) / (b[1] - a[1]), bbox2[3]] : edge & 4 ? [a[0] + (b[0] - a[0]) * (bbox2[1] - a[1]) / (b[1] - a[1]), bbox2[1]] : edge & 2 ? [bbox2[2], a[1] + (b[1] - a[1]) * (bbox2[2] - a[0]) / (b[0] - a[0])] : edge & 1 ? [bbox2[0], a[1] + (b[1] - a[1]) * (bbox2[0] - a[0]) / (b[0] - a[0])] : null;
|
|
5505
|
-
}
|
|
5506
|
-
function bitCode(p, bbox2) {
|
|
5507
|
-
var code = 0;
|
|
5508
|
-
if (p[0] < bbox2[0]) code |= 1;
|
|
5509
|
-
else if (p[0] > bbox2[2]) code |= 2;
|
|
5510
|
-
if (p[1] < bbox2[1]) code |= 4;
|
|
5511
|
-
else if (p[1] > bbox2[3]) code |= 8;
|
|
5512
|
-
return code;
|
|
5513
|
-
}
|
|
5514
|
-
function bboxClip(feature2, bbox2) {
|
|
5515
|
-
const geom = getGeom(feature2);
|
|
5516
|
-
const type = geom.type;
|
|
5517
|
-
const properties = feature2.type === "Feature" ? feature2.properties : {};
|
|
5518
|
-
let coords = geom.coordinates;
|
|
5519
|
-
switch (type) {
|
|
5520
|
-
case "LineString":
|
|
5521
|
-
case "MultiLineString": {
|
|
5522
|
-
const lines = [];
|
|
5523
|
-
if (type === "LineString") {
|
|
5524
|
-
coords = [coords];
|
|
5525
|
-
}
|
|
5526
|
-
coords.forEach((line) => {
|
|
5527
|
-
lineclip(line, bbox2, lines);
|
|
5528
|
-
});
|
|
5529
|
-
if (lines.length === 1) {
|
|
5530
|
-
return lineString(lines[0], properties);
|
|
5531
|
-
}
|
|
5532
|
-
return multiLineString(lines, properties);
|
|
5533
|
-
}
|
|
5534
|
-
case "Polygon":
|
|
5535
|
-
return polygon(clipPolygon(coords, bbox2), properties);
|
|
5536
|
-
case "MultiPolygon":
|
|
5537
|
-
return multiPolygon(
|
|
5538
|
-
coords.map((poly) => {
|
|
5539
|
-
return clipPolygon(poly, bbox2);
|
|
5540
|
-
}),
|
|
5541
|
-
properties
|
|
5542
|
-
);
|
|
5543
|
-
default:
|
|
5544
|
-
throw new Error("geometry " + type + " not supported");
|
|
5545
|
-
}
|
|
5546
|
-
}
|
|
5547
|
-
function clipPolygon(rings, bbox2) {
|
|
5548
|
-
const outRings = [];
|
|
5549
|
-
for (const ring of rings) {
|
|
5550
|
-
const clipped = polygonclip(ring, bbox2);
|
|
5551
|
-
if (clipped.length > 0) {
|
|
5552
|
-
if (clipped[0][0] !== clipped[clipped.length - 1][0] || clipped[0][1] !== clipped[clipped.length - 1][1]) {
|
|
5553
|
-
clipped.push(clipped[0]);
|
|
5554
|
-
}
|
|
5555
|
-
if (clipped.length >= 4) {
|
|
5556
|
-
outRings.push(clipped);
|
|
5557
|
-
}
|
|
5558
|
-
}
|
|
5559
|
-
}
|
|
5560
|
-
return outRings;
|
|
5561
|
-
}
|
|
5562
|
-
var turf_bbox_clip_default = bboxClip;
|
|
5563
|
-
|
|
5564
|
-
// src/filters/tileFeaturesSpatialIndex.ts
|
|
5565
|
-
var import_h3_js = require("h3-js");
|
|
5614
|
+
var import_quadbin2 = require("quadbin");
|
|
5615
|
+
var import_h3_js2 = require("h3-js");
|
|
5566
5616
|
function tileFeaturesSpatialIndex({
|
|
5567
5617
|
tiles,
|
|
5568
5618
|
spatialFilter,
|
|
@@ -5571,58 +5621,52 @@ function tileFeaturesSpatialIndex({
|
|
|
5571
5621
|
}) {
|
|
5572
5622
|
const map = /* @__PURE__ */ new Map();
|
|
5573
5623
|
const spatialIndex = getSpatialIndex(spatialDataType);
|
|
5574
|
-
const
|
|
5624
|
+
const cellResolution = getResolution(tiles, spatialIndex);
|
|
5575
5625
|
const spatialIndexIDName = spatialDataColumn ? spatialDataColumn : spatialIndex;
|
|
5576
|
-
if (!
|
|
5626
|
+
if (!cellResolution) {
|
|
5577
5627
|
return [];
|
|
5578
5628
|
}
|
|
5579
|
-
|
|
5580
|
-
if (
|
|
5581
|
-
|
|
5629
|
+
let intersection3;
|
|
5630
|
+
if (spatialIndex === "h3" /* H3 */) {
|
|
5631
|
+
intersection3 = intersectTileH3(cellResolution, spatialFilter);
|
|
5582
5632
|
}
|
|
5583
|
-
const cellsSet = new Set(cells);
|
|
5584
5633
|
for (const tile of tiles) {
|
|
5585
5634
|
if (tile.isVisible === false || !tile.data) {
|
|
5586
5635
|
continue;
|
|
5587
5636
|
}
|
|
5637
|
+
if (spatialIndex === "quadbin" /* QUADBIN */) {
|
|
5638
|
+
const parent = getTileIndex(tile, spatialIndex);
|
|
5639
|
+
intersection3 = intersectTileQuadbin(
|
|
5640
|
+
parent,
|
|
5641
|
+
cellResolution,
|
|
5642
|
+
spatialFilter
|
|
5643
|
+
);
|
|
5644
|
+
}
|
|
5645
|
+
if (!intersection3) continue;
|
|
5588
5646
|
tile.data.forEach((d) => {
|
|
5589
|
-
if (
|
|
5647
|
+
if (intersection3 === true || intersection3.has(d.id)) {
|
|
5590
5648
|
map.set(d.id, { ...d.properties, [spatialIndexIDName]: d.id });
|
|
5591
5649
|
}
|
|
5592
5650
|
});
|
|
5593
5651
|
}
|
|
5594
5652
|
return Array.from(map.values());
|
|
5595
5653
|
}
|
|
5654
|
+
function getTileIndex(tile, spatialIndex) {
|
|
5655
|
+
if (spatialIndex === "quadbin" /* QUADBIN */) {
|
|
5656
|
+
return tile.index.q;
|
|
5657
|
+
}
|
|
5658
|
+
return tile.id;
|
|
5659
|
+
}
|
|
5596
5660
|
function getResolution(tiles, spatialIndex) {
|
|
5597
5661
|
const data = tiles.find((tile) => tile.data?.length)?.data;
|
|
5598
5662
|
if (!data) {
|
|
5599
5663
|
return;
|
|
5600
5664
|
}
|
|
5601
5665
|
if (spatialIndex === "quadbin" /* QUADBIN */) {
|
|
5602
|
-
return Number((0,
|
|
5666
|
+
return Number((0, import_quadbin2.getResolution)(data[0].id));
|
|
5603
5667
|
}
|
|
5604
5668
|
if (spatialIndex === "h3" /* H3 */) {
|
|
5605
|
-
return (0,
|
|
5606
|
-
}
|
|
5607
|
-
}
|
|
5608
|
-
var bboxWest = [-180, -90, 0, 90];
|
|
5609
|
-
var bboxEast = [0, -90, 180, 90];
|
|
5610
|
-
function getCellsCoverGeometry(geometry, spatialIndex, resolution) {
|
|
5611
|
-
if (spatialIndex === "quadbin" /* QUADBIN */) {
|
|
5612
|
-
return (0, import_quadbin.geometryToCells)(geometry, resolution);
|
|
5613
|
-
}
|
|
5614
|
-
if (spatialIndex === "h3" /* H3 */) {
|
|
5615
|
-
return (0, import_h3_js.polygonToCells)(
|
|
5616
|
-
turf_bbox_clip_default(geometry, bboxWest).geometry.coordinates,
|
|
5617
|
-
resolution,
|
|
5618
|
-
true
|
|
5619
|
-
).concat(
|
|
5620
|
-
(0, import_h3_js.polygonToCells)(
|
|
5621
|
-
turf_bbox_clip_default(geometry, bboxEast).geometry.coordinates,
|
|
5622
|
-
resolution,
|
|
5623
|
-
true
|
|
5624
|
-
)
|
|
5625
|
-
);
|
|
5669
|
+
return (0, import_h3_js2.getResolution)(data[0].id);
|
|
5626
5670
|
}
|
|
5627
5671
|
}
|
|
5628
5672
|
function getSpatialIndex(spatialDataType) {
|
|
@@ -5650,7 +5694,7 @@ var DEFAULT_AGGREGATION_EXP = `1 AS ${DEFAULT_AGGREGATION_EXP_ALIAS}`;
|
|
|
5650
5694
|
|
|
5651
5695
|
// src/filters/tileFeaturesRaster.ts
|
|
5652
5696
|
init_cjs_shims();
|
|
5653
|
-
var
|
|
5697
|
+
var import_quadbin3 = require("quadbin");
|
|
5654
5698
|
function tileFeaturesRaster({
|
|
5655
5699
|
tiles,
|
|
5656
5700
|
...options
|
|
@@ -5661,21 +5705,21 @@ function tileFeaturesRaster({
|
|
|
5661
5705
|
}
|
|
5662
5706
|
tiles = tiles.filter(isRasterTileVisible);
|
|
5663
5707
|
if (tiles.length === 0) return [];
|
|
5664
|
-
const tileResolution = (0,
|
|
5708
|
+
const tileResolution = (0, import_quadbin3.getResolution)(tiles[0].index.q);
|
|
5665
5709
|
const tileBlockSize = tiles[0].data.blockSize;
|
|
5666
5710
|
const cellResolution = tileResolution + BigInt(Math.log2(tileBlockSize));
|
|
5667
5711
|
const data = /* @__PURE__ */ new Map();
|
|
5668
5712
|
for (const tile of tiles) {
|
|
5669
5713
|
const parent = tile.index.q;
|
|
5670
|
-
const
|
|
5671
|
-
|
|
5672
|
-
|
|
5714
|
+
const intersection3 = intersectTileRaster(
|
|
5715
|
+
parent,
|
|
5716
|
+
cellResolution,
|
|
5717
|
+
options.spatialFilter
|
|
5673
5718
|
);
|
|
5674
|
-
|
|
5675
|
-
const tileFilterCells = needsFilter ? new Set((0, import_quadbin2.geometryToCells)(tileFilter.geometry, cellResolution)) : null;
|
|
5719
|
+
if (intersection3 === false) continue;
|
|
5676
5720
|
const tileSortedCells = cellToChildrenSorted(parent, cellResolution);
|
|
5677
5721
|
for (let i = 0; i < tileSortedCells.length; i++) {
|
|
5678
|
-
if (
|
|
5722
|
+
if (intersection3 !== true && !intersection3.has(tileSortedCells[i])) {
|
|
5679
5723
|
continue;
|
|
5680
5724
|
}
|
|
5681
5725
|
const cellData = {};
|
|
@@ -5702,10 +5746,10 @@ function isRasterTileVisible(tile) {
|
|
|
5702
5746
|
return !!(tile.isVisible && tile.data?.cells?.numericProps);
|
|
5703
5747
|
}
|
|
5704
5748
|
function cellToChildrenSorted(parent, resolution) {
|
|
5705
|
-
return (0,
|
|
5749
|
+
return (0, import_quadbin3.cellToChildren)(parent, resolution).sort(
|
|
5706
5750
|
(cellA, cellB) => {
|
|
5707
|
-
const tileA = (0,
|
|
5708
|
-
const tileB = (0,
|
|
5751
|
+
const tileA = (0, import_quadbin3.cellToTile)(cellA);
|
|
5752
|
+
const tileB = (0, import_quadbin3.cellToTile)(cellB);
|
|
5709
5753
|
if (tileA.y !== tileB.y) {
|
|
5710
5754
|
return tileA.y > tileB.y ? 1 : -1;
|
|
5711
5755
|
}
|
|
@@ -6509,6 +6553,10 @@ function getApplicableFilters(owner, filters) {
|
|
|
6509
6553
|
return applicableFilters;
|
|
6510
6554
|
}
|
|
6511
6555
|
|
|
6556
|
+
// src/widget-sources/constants.ts
|
|
6557
|
+
init_cjs_shims();
|
|
6558
|
+
var OTHERS_CATEGORY_NAME = "_carto_others";
|
|
6559
|
+
|
|
6512
6560
|
// src/widget-sources/widget-remote-source.ts
|
|
6513
6561
|
var WidgetRemoteSource = class extends WidgetSource {
|
|
6514
6562
|
_getModelSource(filters, filterOwner) {
|
|
@@ -6532,13 +6580,21 @@ var WidgetRemoteSource = class extends WidgetSource {
|
|
|
6532
6580
|
filterOwner,
|
|
6533
6581
|
spatialFilter,
|
|
6534
6582
|
spatialFiltersMode,
|
|
6583
|
+
rawResult,
|
|
6535
6584
|
...params
|
|
6536
6585
|
} = options;
|
|
6537
|
-
const {
|
|
6586
|
+
const {
|
|
6587
|
+
column,
|
|
6588
|
+
operation: operation2,
|
|
6589
|
+
operationColumn,
|
|
6590
|
+
operationExp,
|
|
6591
|
+
othersThreshold,
|
|
6592
|
+
orderBy
|
|
6593
|
+
} = params;
|
|
6538
6594
|
if (operation2 === AggregationTypes.Custom) {
|
|
6539
6595
|
assert2(operationExp, "operationExp is required for custom operation");
|
|
6540
6596
|
}
|
|
6541
|
-
|
|
6597
|
+
const result = await executeModel({
|
|
6542
6598
|
model: "category",
|
|
6543
6599
|
source: {
|
|
6544
6600
|
...this.getModelSource(filters, filterOwner),
|
|
@@ -6549,10 +6605,23 @@ var WidgetRemoteSource = class extends WidgetSource {
|
|
|
6549
6605
|
column,
|
|
6550
6606
|
operation: operation2,
|
|
6551
6607
|
operationExp,
|
|
6552
|
-
operationColumn: operationColumn || column
|
|
6608
|
+
operationColumn: operationColumn || column,
|
|
6609
|
+
othersThreshold,
|
|
6610
|
+
orderBy
|
|
6553
6611
|
},
|
|
6554
6612
|
opts: { signal, headers: this.props.headers }
|
|
6555
|
-
})
|
|
6613
|
+
});
|
|
6614
|
+
const normalizedRows = normalizeObjectKeys(result.rows || []);
|
|
6615
|
+
if (rawResult) {
|
|
6616
|
+
return result;
|
|
6617
|
+
}
|
|
6618
|
+
if (!othersThreshold) {
|
|
6619
|
+
return normalizedRows;
|
|
6620
|
+
}
|
|
6621
|
+
return [
|
|
6622
|
+
...normalizedRows,
|
|
6623
|
+
{ name: OTHERS_CATEGORY_NAME, value: result?.metadata?.others }
|
|
6624
|
+
];
|
|
6556
6625
|
}
|
|
6557
6626
|
async getFeatures(options) {
|
|
6558
6627
|
const {
|
|
@@ -6957,10 +7026,12 @@ function groupValuesByColumn({
|
|
|
6957
7026
|
valuesColumns,
|
|
6958
7027
|
joinOperation,
|
|
6959
7028
|
keysColumn,
|
|
6960
|
-
operation: operation2
|
|
7029
|
+
operation: operation2,
|
|
7030
|
+
othersThreshold,
|
|
7031
|
+
orderBy = "frequency_desc"
|
|
6961
7032
|
}) {
|
|
6962
7033
|
if (Array.isArray(data) && data.length === 0) {
|
|
6963
|
-
return null;
|
|
7034
|
+
return { rows: null };
|
|
6964
7035
|
}
|
|
6965
7036
|
const groups = data.reduce((accumulator, item) => {
|
|
6966
7037
|
const group2 = item[keysColumn];
|
|
@@ -6975,13 +7046,44 @@ function groupValuesByColumn({
|
|
|
6975
7046
|
return accumulator;
|
|
6976
7047
|
}, /* @__PURE__ */ new Map());
|
|
6977
7048
|
const targetOperation = aggregationFunctions[operation2];
|
|
6978
|
-
if (targetOperation) {
|
|
6979
|
-
return
|
|
6980
|
-
|
|
6981
|
-
|
|
6982
|
-
|
|
7049
|
+
if (!targetOperation) {
|
|
7050
|
+
return { rows: [] };
|
|
7051
|
+
}
|
|
7052
|
+
const allCategories = Array.from(groups).map(([name, value]) => ({
|
|
7053
|
+
name,
|
|
7054
|
+
value: targetOperation(value)
|
|
7055
|
+
})).sort(getSorter(orderBy));
|
|
7056
|
+
if (othersThreshold && allCategories.length > othersThreshold) {
|
|
7057
|
+
const otherValue = allCategories.slice(othersThreshold).flatMap(({ name }) => groups.get(name));
|
|
7058
|
+
allCategories.push({
|
|
7059
|
+
name: OTHERS_CATEGORY_NAME,
|
|
7060
|
+
value: targetOperation(otherValue)
|
|
7061
|
+
});
|
|
7062
|
+
return {
|
|
7063
|
+
rows: allCategories,
|
|
7064
|
+
metadata: {
|
|
7065
|
+
others: targetOperation(otherValue)
|
|
7066
|
+
}
|
|
7067
|
+
};
|
|
7068
|
+
}
|
|
7069
|
+
return {
|
|
7070
|
+
rows: allCategories
|
|
7071
|
+
};
|
|
7072
|
+
}
|
|
7073
|
+
function getSorter(orderBy) {
|
|
7074
|
+
switch (orderBy) {
|
|
7075
|
+
case "frequency_asc":
|
|
7076
|
+
return (a, b) => a.value - b.value || localeCompare(a.name, b.name);
|
|
7077
|
+
case "frequency_desc":
|
|
7078
|
+
return (a, b) => b.value - a.value || localeCompare(a.name, b.name);
|
|
7079
|
+
case "alphabetical_asc":
|
|
7080
|
+
return (a, b) => localeCompare(a.name, b.name) || b.value - a.value;
|
|
7081
|
+
case "alphabetical_desc":
|
|
7082
|
+
return (a, b) => localeCompare(b.name, a.name) || b.value - a.value;
|
|
6983
7083
|
}
|
|
6984
|
-
|
|
7084
|
+
}
|
|
7085
|
+
function localeCompare(a, b) {
|
|
7086
|
+
return (a ?? "null").localeCompare(b ?? "null");
|
|
6985
7087
|
}
|
|
6986
7088
|
|
|
6987
7089
|
// src/operations/groupByDate.ts
|
|
@@ -7466,7 +7568,7 @@ var WidgetTilesetSourceImpl = class extends WidgetSource {
|
|
|
7466
7568
|
}
|
|
7467
7569
|
_extractTileFeatures(spatialFilter) {
|
|
7468
7570
|
const prevInputs = this._tileFeatureExtractPreviousInputs;
|
|
7469
|
-
if (this._features.length &&
|
|
7571
|
+
if (this._features.length && spatialFilterEquals(prevInputs.spatialFilter, spatialFilter)) {
|
|
7470
7572
|
return;
|
|
7471
7573
|
}
|
|
7472
7574
|
this._features = tileFeatures({
|
|
@@ -7555,7 +7657,10 @@ var WidgetTilesetSourceImpl = class extends WidgetSource {
|
|
|
7555
7657
|
joinOperation,
|
|
7556
7658
|
filters,
|
|
7557
7659
|
filterOwner,
|
|
7558
|
-
spatialFilter
|
|
7660
|
+
spatialFilter,
|
|
7661
|
+
othersThreshold,
|
|
7662
|
+
orderBy = "frequency_desc",
|
|
7663
|
+
rawResult
|
|
7559
7664
|
}) {
|
|
7560
7665
|
const filteredFeatures = this._getFilteredFeatures(
|
|
7561
7666
|
spatialFilter,
|
|
@@ -7566,14 +7671,25 @@ var WidgetTilesetSourceImpl = class extends WidgetSource {
|
|
|
7566
7671
|
return [];
|
|
7567
7672
|
}
|
|
7568
7673
|
assertColumn(this._features, column, operationColumn);
|
|
7569
|
-
const
|
|
7674
|
+
const result = groupValuesByColumn({
|
|
7570
7675
|
data: filteredFeatures,
|
|
7571
7676
|
valuesColumns: normalizeColumns(operationColumn || column),
|
|
7572
7677
|
joinOperation,
|
|
7573
7678
|
keysColumn: column,
|
|
7574
|
-
operation: operation2
|
|
7679
|
+
operation: operation2,
|
|
7680
|
+
othersThreshold,
|
|
7681
|
+
orderBy
|
|
7575
7682
|
});
|
|
7576
|
-
|
|
7683
|
+
if (rawResult) {
|
|
7684
|
+
return result;
|
|
7685
|
+
}
|
|
7686
|
+
if (!othersThreshold) {
|
|
7687
|
+
return result?.rows || [];
|
|
7688
|
+
}
|
|
7689
|
+
return [
|
|
7690
|
+
...result?.rows || [],
|
|
7691
|
+
{ name: OTHERS_CATEGORY_NAME, value: result?.metadata?.others }
|
|
7692
|
+
];
|
|
7577
7693
|
}
|
|
7578
7694
|
async getScatter({
|
|
7579
7695
|
xAxisColumn,
|
|
@@ -7706,7 +7822,6 @@ var WidgetTilesetSourceImpl = class extends WidgetSource {
|
|
|
7706
7822
|
* INTERNAL
|
|
7707
7823
|
*/
|
|
7708
7824
|
_getFilteredFeatures(spatialFilter, filters, filterOwner) {
|
|
7709
|
-
assert2(spatialFilter, "spatialFilter required for tilesets");
|
|
7710
7825
|
this._extractTileFeatures(spatialFilter);
|
|
7711
7826
|
return applyFilters(
|
|
7712
7827
|
this._features,
|
|
@@ -7730,6 +7845,11 @@ function assertColumn(features, ...columnArgs) {
|
|
|
7730
7845
|
function normalizeColumns(columns) {
|
|
7731
7846
|
return Array.isArray(columns) ? columns : typeof columns === "string" ? [columns] : [];
|
|
7732
7847
|
}
|
|
7848
|
+
function spatialFilterEquals(a, b) {
|
|
7849
|
+
if (a === b) return true;
|
|
7850
|
+
if (!a || !b) return false;
|
|
7851
|
+
return booleanEqual(a, b);
|
|
7852
|
+
}
|
|
7733
7853
|
|
|
7734
7854
|
// src/widget-sources/widget-tileset-source.ts
|
|
7735
7855
|
var WidgetTilesetSource = class extends WidgetSource {
|
|
@@ -10362,6 +10482,7 @@ function hashBuckets(initialCount) {
|
|
|
10362
10482
|
FEATURE_GEOM_PROPERTY,
|
|
10363
10483
|
FilterType,
|
|
10364
10484
|
OPACITY_MAP,
|
|
10485
|
+
OTHERS_CATEGORY_NAME,
|
|
10365
10486
|
Provider,
|
|
10366
10487
|
SOURCE_DEFAULTS,
|
|
10367
10488
|
SchemaFieldType,
|
|
@@ -10412,6 +10533,7 @@ function hashBuckets(initialCount) {
|
|
|
10412
10533
|
getLayerProps,
|
|
10413
10534
|
getMaxMarkerSize,
|
|
10414
10535
|
getSizeAccessor,
|
|
10536
|
+
getSorter,
|
|
10415
10537
|
getSpatialIndexFromGeoColumn,
|
|
10416
10538
|
getTextAccessor,
|
|
10417
10539
|
groupValuesByColumn,
|