@carto/api-client 0.5.7-alpha-optional-spatial-filter.0 → 0.5.7-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/build/api-client.cjs +437 -414
- 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 +401 -382
- package/build/api-client.js.map +1 -1
- package/build/worker-compat.js +865 -900
- package/build/worker-compat.js.map +1 -1
- package/build/worker.js +374 -378
- package/build/worker.js.map +1 -1
- package/package.json +1 -1
- package/src/filters/tileFeatures.ts +1 -1
- package/src/filters/tileFeaturesGeometries.ts +55 -28
- package/src/filters/tileFeaturesRaster.ts +21 -10
- package/src/filters/tileFeaturesSpatialIndex.ts +52 -37
- 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 +23 -10
- package/src/filters/tileIntersection.ts +0 -158
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,143 +1729,6 @@ init_cjs_shims();
|
|
|
1727
1729
|
// src/filters/tileFeaturesGeometries.ts
|
|
1728
1730
|
init_cjs_shims();
|
|
1729
1731
|
|
|
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
|
-
|
|
1867
1732
|
// node_modules/@turf/bbox-polygon/dist/esm/index.js
|
|
1868
1733
|
init_cjs_shims();
|
|
1869
1734
|
function bboxPolygon(bbox2, options = {}) {
|
|
@@ -2195,7 +2060,7 @@ var MAX_SAFE_INTEGER = 9007199254740991;
|
|
|
2195
2060
|
var POWS_TEN = [1, 10, 100, 1e3, 1e4, 1e5, 1e6, 1e7, 1e8, 1e9, 1e10, 1e11, 1e12, 1e13];
|
|
2196
2061
|
var SQRT_BASE = 1e7;
|
|
2197
2062
|
var MAX = 1e9;
|
|
2198
|
-
function
|
|
2063
|
+
function clone(configObject) {
|
|
2199
2064
|
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 = {
|
|
2200
2065
|
prefix: "",
|
|
2201
2066
|
groupSize: 3,
|
|
@@ -2321,7 +2186,7 @@ function clone2(configObject) {
|
|
|
2321
2186
|
x.c = [x.e = 0];
|
|
2322
2187
|
}
|
|
2323
2188
|
}
|
|
2324
|
-
BigNumber2.clone =
|
|
2189
|
+
BigNumber2.clone = clone;
|
|
2325
2190
|
BigNumber2.ROUND_UP = 0;
|
|
2326
2191
|
BigNumber2.ROUND_DOWN = 1;
|
|
2327
2192
|
BigNumber2.ROUND_CEIL = 2;
|
|
@@ -3524,7 +3389,7 @@ function toFixedPoint(str, e, z) {
|
|
|
3524
3389
|
}
|
|
3525
3390
|
return str;
|
|
3526
3391
|
}
|
|
3527
|
-
var BigNumber =
|
|
3392
|
+
var BigNumber = clone();
|
|
3528
3393
|
var bignumber_default = BigNumber;
|
|
3529
3394
|
|
|
3530
3395
|
// node_modules/splaytree-ts/dist/esm/index.js
|
|
@@ -5097,13 +4962,99 @@ var turf_intersect_default = intersect;
|
|
|
5097
4962
|
|
|
5098
4963
|
// src/utils/transformToTileCoords.ts
|
|
5099
4964
|
init_cjs_shims();
|
|
5100
|
-
|
|
5101
|
-
|
|
5102
|
-
|
|
5103
|
-
|
|
5104
|
-
|
|
5105
|
-
|
|
5106
|
-
|
|
4965
|
+
|
|
4966
|
+
// node_modules/@math.gl/web-mercator/dist/index.js
|
|
4967
|
+
init_cjs_shims();
|
|
4968
|
+
|
|
4969
|
+
// node_modules/@math.gl/web-mercator/dist/web-mercator-viewport.js
|
|
4970
|
+
init_cjs_shims();
|
|
4971
|
+
|
|
4972
|
+
// node_modules/@math.gl/web-mercator/dist/math-utils.js
|
|
4973
|
+
init_cjs_shims();
|
|
4974
|
+
|
|
4975
|
+
// node_modules/@math.gl/core/dist/index.js
|
|
4976
|
+
init_cjs_shims();
|
|
4977
|
+
|
|
4978
|
+
// node_modules/@math.gl/core/dist/lib/common.js
|
|
4979
|
+
init_cjs_shims();
|
|
4980
|
+
var RADIANS_TO_DEGREES = 1 / Math.PI * 180;
|
|
4981
|
+
var DEGREES_TO_RADIANS = 1 / 180 * Math.PI;
|
|
4982
|
+
var DEFAULT_CONFIG = {
|
|
4983
|
+
EPSILON: 1e-12,
|
|
4984
|
+
debug: false,
|
|
4985
|
+
precision: 4,
|
|
4986
|
+
printTypes: false,
|
|
4987
|
+
printDegrees: false,
|
|
4988
|
+
printRowMajor: true,
|
|
4989
|
+
_cartographicRadians: false
|
|
4990
|
+
};
|
|
4991
|
+
globalThis.mathgl = globalThis.mathgl || { config: { ...DEFAULT_CONFIG } };
|
|
4992
|
+
var config = globalThis.mathgl.config;
|
|
4993
|
+
function isArray(value) {
|
|
4994
|
+
return Array.isArray(value) || ArrayBuffer.isView(value) && !(value instanceof DataView);
|
|
4995
|
+
}
|
|
4996
|
+
function lerp(a, b, t) {
|
|
4997
|
+
if (isArray(a)) {
|
|
4998
|
+
return a.map((ai, i) => lerp(ai, b[i], t));
|
|
4999
|
+
}
|
|
5000
|
+
return t * b + (1 - t) * a;
|
|
5001
|
+
}
|
|
5002
|
+
|
|
5003
|
+
// node_modules/@math.gl/web-mercator/dist/web-mercator-utils.js
|
|
5004
|
+
init_cjs_shims();
|
|
5005
|
+
|
|
5006
|
+
// node_modules/@math.gl/web-mercator/dist/assert.js
|
|
5007
|
+
init_cjs_shims();
|
|
5008
|
+
function assert(condition, message) {
|
|
5009
|
+
if (!condition) {
|
|
5010
|
+
throw new Error(message || "@math.gl/web-mercator: assertion failed.");
|
|
5011
|
+
}
|
|
5012
|
+
}
|
|
5013
|
+
|
|
5014
|
+
// node_modules/@math.gl/web-mercator/dist/web-mercator-utils.js
|
|
5015
|
+
var PI = Math.PI;
|
|
5016
|
+
var PI_4 = PI / 4;
|
|
5017
|
+
var DEGREES_TO_RADIANS2 = PI / 180;
|
|
5018
|
+
var RADIANS_TO_DEGREES2 = 180 / PI;
|
|
5019
|
+
var TILE_SIZE = 512;
|
|
5020
|
+
function lngLatToWorld(lngLat) {
|
|
5021
|
+
const [lng, lat] = lngLat;
|
|
5022
|
+
assert(Number.isFinite(lng));
|
|
5023
|
+
assert(Number.isFinite(lat) && lat >= -90 && lat <= 90, "invalid latitude");
|
|
5024
|
+
const lambda2 = lng * DEGREES_TO_RADIANS2;
|
|
5025
|
+
const phi2 = lat * DEGREES_TO_RADIANS2;
|
|
5026
|
+
const x = TILE_SIZE * (lambda2 + PI) / (2 * PI);
|
|
5027
|
+
const y = TILE_SIZE * (PI + Math.log(Math.tan(PI_4 + phi2 * 0.5))) / (2 * PI);
|
|
5028
|
+
return [x, y];
|
|
5029
|
+
}
|
|
5030
|
+
function worldToLngLat(xy) {
|
|
5031
|
+
const [x, y] = xy;
|
|
5032
|
+
const lambda2 = x / TILE_SIZE * (2 * PI) - PI;
|
|
5033
|
+
const phi2 = 2 * (Math.atan(Math.exp(y / TILE_SIZE * (2 * PI) - PI)) - PI_4);
|
|
5034
|
+
return [lambda2 * RADIANS_TO_DEGREES2, phi2 * RADIANS_TO_DEGREES2];
|
|
5035
|
+
}
|
|
5036
|
+
|
|
5037
|
+
// node_modules/@math.gl/web-mercator/dist/fit-bounds.js
|
|
5038
|
+
init_cjs_shims();
|
|
5039
|
+
|
|
5040
|
+
// node_modules/@math.gl/web-mercator/dist/get-bounds.js
|
|
5041
|
+
init_cjs_shims();
|
|
5042
|
+
var DEGREES_TO_RADIANS3 = Math.PI / 180;
|
|
5043
|
+
|
|
5044
|
+
// node_modules/@math.gl/web-mercator/dist/normalize-viewport-props.js
|
|
5045
|
+
init_cjs_shims();
|
|
5046
|
+
|
|
5047
|
+
// node_modules/@math.gl/web-mercator/dist/fly-to-viewport.js
|
|
5048
|
+
init_cjs_shims();
|
|
5049
|
+
|
|
5050
|
+
// src/utils/transformToTileCoords.ts
|
|
5051
|
+
var TRANSFORM_FN = {
|
|
5052
|
+
Point: transformPoint,
|
|
5053
|
+
MultiPoint: transformMultiPoint,
|
|
5054
|
+
LineString: transformLineString,
|
|
5055
|
+
MultiLineString: transformMultiLineString,
|
|
5056
|
+
Polygon: transformPolygon,
|
|
5057
|
+
MultiPolygon: transformMultiPolygon
|
|
5107
5058
|
};
|
|
5108
5059
|
function transformToTileCoords(geometry, bbox2) {
|
|
5109
5060
|
const [west, south, east, north] = bbox2;
|
|
@@ -5113,34 +5064,34 @@ function transformToTileCoords(geometry, bbox2) {
|
|
|
5113
5064
|
if (geometry.type === "GeometryCollection") {
|
|
5114
5065
|
throw new Error("Unsupported geometry type GeometryCollection");
|
|
5115
5066
|
}
|
|
5116
|
-
const transformFn =
|
|
5067
|
+
const transformFn = TRANSFORM_FN[geometry.type];
|
|
5117
5068
|
const coordinates = transformFn(geometry.coordinates, projectedBbox);
|
|
5118
5069
|
return { ...geometry, coordinates };
|
|
5119
5070
|
}
|
|
5120
|
-
function
|
|
5071
|
+
function transformPoint([pointX, pointY], [nw, se]) {
|
|
5121
5072
|
const x = inverseLerp(nw[0], se[0], pointX);
|
|
5122
5073
|
const y = inverseLerp(nw[1], se[1], pointY);
|
|
5123
5074
|
return [x, y];
|
|
5124
5075
|
}
|
|
5125
|
-
function
|
|
5126
|
-
return geometry.map((g) =>
|
|
5076
|
+
function getPoints(geometry, bbox2) {
|
|
5077
|
+
return geometry.map((g) => transformPoint(projectFlat(g), bbox2));
|
|
5127
5078
|
}
|
|
5128
|
-
function
|
|
5129
|
-
return
|
|
5079
|
+
function transformMultiPoint(multiPoint, bbox2) {
|
|
5080
|
+
return getPoints(multiPoint, bbox2);
|
|
5130
5081
|
}
|
|
5131
|
-
function
|
|
5132
|
-
return
|
|
5082
|
+
function transformLineString(line, bbox2) {
|
|
5083
|
+
return getPoints(line, bbox2);
|
|
5133
5084
|
}
|
|
5134
|
-
function
|
|
5085
|
+
function transformMultiLineString(multiLineString2, bbox2) {
|
|
5135
5086
|
return multiLineString2.map(
|
|
5136
|
-
(lineString2) =>
|
|
5087
|
+
(lineString2) => transformLineString(lineString2, bbox2)
|
|
5137
5088
|
);
|
|
5138
5089
|
}
|
|
5139
|
-
function
|
|
5140
|
-
return polygon2.map((polygonRing) =>
|
|
5141
|
-
}
|
|
5142
|
-
function
|
|
5143
|
-
return multiPolygon2.map((polygon2) =>
|
|
5090
|
+
function transformPolygon(polygon2, bbox2) {
|
|
5091
|
+
return polygon2.map((polygonRing) => getPoints(polygonRing, bbox2));
|
|
5092
|
+
}
|
|
5093
|
+
function transformMultiPolygon(multiPolygon2, bbox2) {
|
|
5094
|
+
return multiPolygon2.map((polygon2) => transformPolygon(polygon2, bbox2));
|
|
5144
5095
|
}
|
|
5145
5096
|
function projectFlat(xyz) {
|
|
5146
5097
|
return lngLatToWorld(xyz);
|
|
@@ -5149,190 +5100,52 @@ function inverseLerp(a, b, x) {
|
|
|
5149
5100
|
return (x - a) / (b - a);
|
|
5150
5101
|
}
|
|
5151
5102
|
|
|
5152
|
-
// src/
|
|
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
|
|
5103
|
+
// src/utils/transformTileCoordsToWGS84.ts
|
|
5157
5104
|
init_cjs_shims();
|
|
5158
|
-
|
|
5159
|
-
|
|
5160
|
-
|
|
5161
|
-
|
|
5162
|
-
|
|
5163
|
-
|
|
5164
|
-
|
|
5165
|
-
|
|
5166
|
-
|
|
5167
|
-
|
|
5168
|
-
|
|
5169
|
-
|
|
5170
|
-
|
|
5171
|
-
|
|
5172
|
-
|
|
5173
|
-
result.push(part);
|
|
5174
|
-
part = [];
|
|
5175
|
-
}
|
|
5176
|
-
} else if (i === len - 1) {
|
|
5177
|
-
part.push(b);
|
|
5178
|
-
}
|
|
5179
|
-
break;
|
|
5180
|
-
} else if (codeA & codeB) {
|
|
5181
|
-
break;
|
|
5182
|
-
} else if (codeA) {
|
|
5183
|
-
a = intersect2(a, b, codeA, bbox2);
|
|
5184
|
-
codeA = bitCode(a, bbox2);
|
|
5185
|
-
} else {
|
|
5186
|
-
b = intersect2(a, b, codeB, bbox2);
|
|
5187
|
-
codeB = bitCode(b, bbox2);
|
|
5188
|
-
}
|
|
5189
|
-
}
|
|
5190
|
-
codeA = lastCode;
|
|
5191
|
-
}
|
|
5192
|
-
if (part.length) result.push(part);
|
|
5193
|
-
return result;
|
|
5194
|
-
}
|
|
5195
|
-
function polygonclip(points, bbox2) {
|
|
5196
|
-
var result, edge, prev, prevInside, i, p, inside;
|
|
5197
|
-
for (edge = 1; edge <= 8; edge *= 2) {
|
|
5198
|
-
result = [];
|
|
5199
|
-
prev = points[points.length - 1];
|
|
5200
|
-
prevInside = !(bitCode(prev, bbox2) & edge);
|
|
5201
|
-
for (i = 0; i < points.length; i++) {
|
|
5202
|
-
p = points[i];
|
|
5203
|
-
inside = !(bitCode(p, bbox2) & edge);
|
|
5204
|
-
if (inside !== prevInside) result.push(intersect2(prev, p, edge, bbox2));
|
|
5205
|
-
if (inside) result.push(p);
|
|
5206
|
-
prev = p;
|
|
5207
|
-
prevInside = inside;
|
|
5208
|
-
}
|
|
5209
|
-
points = result;
|
|
5210
|
-
if (!points.length) break;
|
|
5105
|
+
var TRANSFORM_FN2 = {
|
|
5106
|
+
Point: transformPoint2,
|
|
5107
|
+
MultiPoint: transformMultiPoint2,
|
|
5108
|
+
LineString: transformLineString2,
|
|
5109
|
+
MultiLineString: transformMultiLineString2,
|
|
5110
|
+
Polygon: transformPolygon2,
|
|
5111
|
+
MultiPolygon: transformMultiPolygon2
|
|
5112
|
+
};
|
|
5113
|
+
function transformTileCoordsToWGS84(geometry, bbox2) {
|
|
5114
|
+
const [west, south, east, north] = bbox2;
|
|
5115
|
+
const nw = lngLatToWorld([west, north]);
|
|
5116
|
+
const se = lngLatToWorld([east, south]);
|
|
5117
|
+
const projectedBbox = [nw, se];
|
|
5118
|
+
if (geometry.type === "GeometryCollection") {
|
|
5119
|
+
throw new Error("Unsupported geometry type GeometryCollection");
|
|
5211
5120
|
}
|
|
5212
|
-
|
|
5121
|
+
const transformFn = TRANSFORM_FN2[geometry.type];
|
|
5122
|
+
const coordinates = transformFn(geometry.coordinates, projectedBbox);
|
|
5123
|
+
return { ...geometry, coordinates };
|
|
5213
5124
|
}
|
|
5214
|
-
function
|
|
5215
|
-
|
|
5125
|
+
function transformPoint2([pointX, pointY], [nw, se]) {
|
|
5126
|
+
const x = lerp(nw[0], se[0], pointX);
|
|
5127
|
+
const y = lerp(nw[1], se[1], pointY);
|
|
5128
|
+
return worldToLngLat([x, y]);
|
|
5216
5129
|
}
|
|
5217
|
-
function
|
|
5218
|
-
|
|
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;
|
|
5130
|
+
function getPoints2(geometry, bbox2) {
|
|
5131
|
+
return geometry.map((g) => transformPoint2(g, bbox2));
|
|
5224
5132
|
}
|
|
5225
|
-
function
|
|
5226
|
-
|
|
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
|
-
}
|
|
5133
|
+
function transformMultiPoint2(multiPoint, bbox2) {
|
|
5134
|
+
return getPoints2(multiPoint, bbox2);
|
|
5257
5135
|
}
|
|
5258
|
-
function
|
|
5259
|
-
|
|
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;
|
|
5136
|
+
function transformLineString2(line, bbox2) {
|
|
5137
|
+
return getPoints2(line, bbox2);
|
|
5272
5138
|
}
|
|
5273
|
-
|
|
5274
|
-
|
|
5275
|
-
|
|
5276
|
-
function intersectTileGeometry(tileBbox, tileFormat, spatialFilter) {
|
|
5277
|
-
const tilePolygon = turf_bbox_polygon_default(tileBbox);
|
|
5278
|
-
if (!spatialFilter || turf_boolean_within_default(tilePolygon, spatialFilter)) {
|
|
5279
|
-
return true;
|
|
5280
|
-
}
|
|
5281
|
-
const clippedSpatialFilter = turf_intersect_default(
|
|
5282
|
-
featureCollection([tilePolygon, feature(spatialFilter)])
|
|
5139
|
+
function transformMultiLineString2(multiLineString2, bbox2) {
|
|
5140
|
+
return multiLineString2.map(
|
|
5141
|
+
(lineString2) => transformLineString2(lineString2, bbox2)
|
|
5283
5142
|
);
|
|
5284
|
-
if (!clippedSpatialFilter) {
|
|
5285
|
-
return false;
|
|
5286
|
-
}
|
|
5287
|
-
return tileFormat === "mvt" /* MVT */ ? transformToTileCoords(clippedSpatialFilter.geometry, tileBbox) : clippedSpatialFilter.geometry;
|
|
5288
5143
|
}
|
|
5289
|
-
function
|
|
5290
|
-
return
|
|
5291
|
-
}
|
|
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);
|
|
5144
|
+
function transformPolygon2(polygon2, bbox2) {
|
|
5145
|
+
return polygon2.map((polygonRing) => getPoints2(polygonRing, bbox2));
|
|
5308
5146
|
}
|
|
5309
|
-
|
|
5310
|
-
|
|
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));
|
|
5147
|
+
function transformMultiPolygon2(multiPolygon2, bbox2) {
|
|
5148
|
+
return multiPolygon2.map((polygon2) => transformPolygon2(polygon2, bbox2));
|
|
5336
5149
|
}
|
|
5337
5150
|
|
|
5338
5151
|
// src/filters/tileFeaturesGeometries.ts
|
|
@@ -5349,45 +5162,55 @@ function tileFeaturesGeometries({
|
|
|
5349
5162
|
if (tile.isVisible === false || !tile.data) {
|
|
5350
5163
|
continue;
|
|
5351
5164
|
}
|
|
5352
|
-
const
|
|
5165
|
+
const bbox2 = [
|
|
5353
5166
|
tile.bbox.west,
|
|
5354
5167
|
tile.bbox.south,
|
|
5355
5168
|
tile.bbox.east,
|
|
5356
5169
|
tile.bbox.north
|
|
5357
5170
|
];
|
|
5358
|
-
const
|
|
5359
|
-
|
|
5360
|
-
|
|
5361
|
-
|
|
5171
|
+
const bboxToGeom = turf_bbox_polygon_default(bbox2);
|
|
5172
|
+
const tileIsFullyVisible = turf_boolean_within_default(bboxToGeom, spatialFilter);
|
|
5173
|
+
const spatialFilterFeature = {
|
|
5174
|
+
type: "Feature",
|
|
5175
|
+
geometry: spatialFilter,
|
|
5176
|
+
properties: {}
|
|
5177
|
+
};
|
|
5178
|
+
const clippedGeometryToIntersect = turf_intersect_default(
|
|
5179
|
+
featureCollection([bboxToGeom, spatialFilterFeature])
|
|
5362
5180
|
);
|
|
5363
|
-
if (
|
|
5364
|
-
|
|
5181
|
+
if (!clippedGeometryToIntersect) {
|
|
5182
|
+
continue;
|
|
5183
|
+
}
|
|
5184
|
+
const transformedGeometryToIntersect = tileFormat === "mvt" /* MVT */ ? transformToTileCoords(clippedGeometryToIntersect.geometry, bbox2) : clippedGeometryToIntersect.geometry;
|
|
5365
5185
|
calculateFeatures({
|
|
5366
5186
|
map,
|
|
5367
|
-
|
|
5187
|
+
tileIsFullyVisible,
|
|
5188
|
+
geometryIntersection: transformedGeometryToIntersect,
|
|
5368
5189
|
data: tile.data.points,
|
|
5369
5190
|
type: "Point",
|
|
5370
|
-
bbox:
|
|
5191
|
+
bbox: bbox2,
|
|
5371
5192
|
tileFormat,
|
|
5372
5193
|
uniqueIdProperty,
|
|
5373
5194
|
options
|
|
5374
5195
|
});
|
|
5375
5196
|
calculateFeatures({
|
|
5376
5197
|
map,
|
|
5377
|
-
|
|
5198
|
+
tileIsFullyVisible,
|
|
5199
|
+
geometryIntersection: transformedGeometryToIntersect,
|
|
5378
5200
|
data: tile.data.lines,
|
|
5379
5201
|
type: "LineString",
|
|
5380
|
-
bbox:
|
|
5202
|
+
bbox: bbox2,
|
|
5381
5203
|
tileFormat,
|
|
5382
5204
|
uniqueIdProperty,
|
|
5383
5205
|
options
|
|
5384
5206
|
});
|
|
5385
5207
|
calculateFeatures({
|
|
5386
5208
|
map,
|
|
5387
|
-
|
|
5209
|
+
tileIsFullyVisible,
|
|
5210
|
+
geometryIntersection: transformedGeometryToIntersect,
|
|
5388
5211
|
data: tile.data.polygons,
|
|
5389
5212
|
type: "Polygon",
|
|
5390
|
-
bbox:
|
|
5213
|
+
bbox: bbox2,
|
|
5391
5214
|
tileFormat,
|
|
5392
5215
|
uniqueIdProperty,
|
|
5393
5216
|
options
|
|
@@ -5405,7 +5228,7 @@ function processTileFeatureProperties({
|
|
|
5405
5228
|
tileFormat,
|
|
5406
5229
|
uniqueIdProperty,
|
|
5407
5230
|
storeGeometry,
|
|
5408
|
-
|
|
5231
|
+
geometryIntersection
|
|
5409
5232
|
}) {
|
|
5410
5233
|
const tileProps = getPropertiesFromTile(data, startIndex);
|
|
5411
5234
|
const uniquePropertyValue = getUniquePropertyValue(
|
|
@@ -5417,7 +5240,7 @@ function processTileFeatureProperties({
|
|
|
5417
5240
|
return;
|
|
5418
5241
|
}
|
|
5419
5242
|
let geometry = null;
|
|
5420
|
-
if (storeGeometry ||
|
|
5243
|
+
if (storeGeometry || geometryIntersection) {
|
|
5421
5244
|
const { positions } = data;
|
|
5422
5245
|
const ringCoordinates = getRingCoordinatesFor(
|
|
5423
5246
|
startIndex,
|
|
@@ -5426,7 +5249,7 @@ function processTileFeatureProperties({
|
|
|
5426
5249
|
);
|
|
5427
5250
|
geometry = getFeatureByType(ringCoordinates, type);
|
|
5428
5251
|
}
|
|
5429
|
-
if (geometry &&
|
|
5252
|
+
if (geometry && geometryIntersection && !turf_boolean_intersects_default(geometry, geometryIntersection)) {
|
|
5430
5253
|
return;
|
|
5431
5254
|
}
|
|
5432
5255
|
const properties = parseProperties(tileProps);
|
|
@@ -5438,7 +5261,7 @@ function processTileFeatureProperties({
|
|
|
5438
5261
|
function addIntersectedFeaturesInTile({
|
|
5439
5262
|
map,
|
|
5440
5263
|
data,
|
|
5441
|
-
|
|
5264
|
+
geometryIntersection,
|
|
5442
5265
|
type,
|
|
5443
5266
|
bbox: bbox2,
|
|
5444
5267
|
tileFormat,
|
|
@@ -5460,7 +5283,7 @@ function addIntersectedFeaturesInTile({
|
|
|
5460
5283
|
tileFormat,
|
|
5461
5284
|
uniqueIdProperty,
|
|
5462
5285
|
storeGeometry,
|
|
5463
|
-
|
|
5286
|
+
geometryIntersection
|
|
5464
5287
|
});
|
|
5465
5288
|
}
|
|
5466
5289
|
}
|
|
@@ -5542,7 +5365,8 @@ function getRingCoordinatesFor(startIndex, endIndex, positions) {
|
|
|
5542
5365
|
}
|
|
5543
5366
|
function calculateFeatures({
|
|
5544
5367
|
map,
|
|
5545
|
-
|
|
5368
|
+
tileIsFullyVisible,
|
|
5369
|
+
geometryIntersection,
|
|
5546
5370
|
data,
|
|
5547
5371
|
type,
|
|
5548
5372
|
bbox: bbox2,
|
|
@@ -5553,7 +5377,7 @@ function calculateFeatures({
|
|
|
5553
5377
|
if (!data?.properties.length) {
|
|
5554
5378
|
return;
|
|
5555
5379
|
}
|
|
5556
|
-
if (
|
|
5380
|
+
if (tileIsFullyVisible) {
|
|
5557
5381
|
addAllFeaturesInTile({
|
|
5558
5382
|
map,
|
|
5559
5383
|
data,
|
|
@@ -5567,7 +5391,7 @@ function calculateFeatures({
|
|
|
5567
5391
|
addIntersectedFeaturesInTile({
|
|
5568
5392
|
map,
|
|
5569
5393
|
data,
|
|
5570
|
-
|
|
5394
|
+
geometryIntersection,
|
|
5571
5395
|
type,
|
|
5572
5396
|
bbox: bbox2,
|
|
5573
5397
|
tileFormat,
|
|
@@ -5618,8 +5442,129 @@ function createIndicesForPoints(data) {
|
|
|
5618
5442
|
|
|
5619
5443
|
// src/filters/tileFeaturesSpatialIndex.ts
|
|
5620
5444
|
init_cjs_shims();
|
|
5621
|
-
var
|
|
5622
|
-
|
|
5445
|
+
var import_quadbin = require("quadbin");
|
|
5446
|
+
|
|
5447
|
+
// node_modules/@turf/bbox-clip/dist/esm/index.js
|
|
5448
|
+
init_cjs_shims();
|
|
5449
|
+
function lineclip(points, bbox2, result) {
|
|
5450
|
+
var len = points.length, codeA = bitCode(points[0], bbox2), part = [], i, codeB, lastCode;
|
|
5451
|
+
let a;
|
|
5452
|
+
let b;
|
|
5453
|
+
if (!result) result = [];
|
|
5454
|
+
for (i = 1; i < len; i++) {
|
|
5455
|
+
a = points[i - 1];
|
|
5456
|
+
b = points[i];
|
|
5457
|
+
codeB = lastCode = bitCode(b, bbox2);
|
|
5458
|
+
while (true) {
|
|
5459
|
+
if (!(codeA | codeB)) {
|
|
5460
|
+
part.push(a);
|
|
5461
|
+
if (codeB !== lastCode) {
|
|
5462
|
+
part.push(b);
|
|
5463
|
+
if (i < len - 1) {
|
|
5464
|
+
result.push(part);
|
|
5465
|
+
part = [];
|
|
5466
|
+
}
|
|
5467
|
+
} else if (i === len - 1) {
|
|
5468
|
+
part.push(b);
|
|
5469
|
+
}
|
|
5470
|
+
break;
|
|
5471
|
+
} else if (codeA & codeB) {
|
|
5472
|
+
break;
|
|
5473
|
+
} else if (codeA) {
|
|
5474
|
+
a = intersect2(a, b, codeA, bbox2);
|
|
5475
|
+
codeA = bitCode(a, bbox2);
|
|
5476
|
+
} else {
|
|
5477
|
+
b = intersect2(a, b, codeB, bbox2);
|
|
5478
|
+
codeB = bitCode(b, bbox2);
|
|
5479
|
+
}
|
|
5480
|
+
}
|
|
5481
|
+
codeA = lastCode;
|
|
5482
|
+
}
|
|
5483
|
+
if (part.length) result.push(part);
|
|
5484
|
+
return result;
|
|
5485
|
+
}
|
|
5486
|
+
function polygonclip(points, bbox2) {
|
|
5487
|
+
var result, edge, prev, prevInside, i, p, inside;
|
|
5488
|
+
for (edge = 1; edge <= 8; edge *= 2) {
|
|
5489
|
+
result = [];
|
|
5490
|
+
prev = points[points.length - 1];
|
|
5491
|
+
prevInside = !(bitCode(prev, bbox2) & edge);
|
|
5492
|
+
for (i = 0; i < points.length; i++) {
|
|
5493
|
+
p = points[i];
|
|
5494
|
+
inside = !(bitCode(p, bbox2) & edge);
|
|
5495
|
+
if (inside !== prevInside) result.push(intersect2(prev, p, edge, bbox2));
|
|
5496
|
+
if (inside) result.push(p);
|
|
5497
|
+
prev = p;
|
|
5498
|
+
prevInside = inside;
|
|
5499
|
+
}
|
|
5500
|
+
points = result;
|
|
5501
|
+
if (!points.length) break;
|
|
5502
|
+
}
|
|
5503
|
+
return result;
|
|
5504
|
+
}
|
|
5505
|
+
function intersect2(a, b, edge, bbox2) {
|
|
5506
|
+
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;
|
|
5507
|
+
}
|
|
5508
|
+
function bitCode(p, bbox2) {
|
|
5509
|
+
var code = 0;
|
|
5510
|
+
if (p[0] < bbox2[0]) code |= 1;
|
|
5511
|
+
else if (p[0] > bbox2[2]) code |= 2;
|
|
5512
|
+
if (p[1] < bbox2[1]) code |= 4;
|
|
5513
|
+
else if (p[1] > bbox2[3]) code |= 8;
|
|
5514
|
+
return code;
|
|
5515
|
+
}
|
|
5516
|
+
function bboxClip(feature2, bbox2) {
|
|
5517
|
+
const geom = getGeom(feature2);
|
|
5518
|
+
const type = geom.type;
|
|
5519
|
+
const properties = feature2.type === "Feature" ? feature2.properties : {};
|
|
5520
|
+
let coords = geom.coordinates;
|
|
5521
|
+
switch (type) {
|
|
5522
|
+
case "LineString":
|
|
5523
|
+
case "MultiLineString": {
|
|
5524
|
+
const lines = [];
|
|
5525
|
+
if (type === "LineString") {
|
|
5526
|
+
coords = [coords];
|
|
5527
|
+
}
|
|
5528
|
+
coords.forEach((line) => {
|
|
5529
|
+
lineclip(line, bbox2, lines);
|
|
5530
|
+
});
|
|
5531
|
+
if (lines.length === 1) {
|
|
5532
|
+
return lineString(lines[0], properties);
|
|
5533
|
+
}
|
|
5534
|
+
return multiLineString(lines, properties);
|
|
5535
|
+
}
|
|
5536
|
+
case "Polygon":
|
|
5537
|
+
return polygon(clipPolygon(coords, bbox2), properties);
|
|
5538
|
+
case "MultiPolygon":
|
|
5539
|
+
return multiPolygon(
|
|
5540
|
+
coords.map((poly) => {
|
|
5541
|
+
return clipPolygon(poly, bbox2);
|
|
5542
|
+
}),
|
|
5543
|
+
properties
|
|
5544
|
+
);
|
|
5545
|
+
default:
|
|
5546
|
+
throw new Error("geometry " + type + " not supported");
|
|
5547
|
+
}
|
|
5548
|
+
}
|
|
5549
|
+
function clipPolygon(rings, bbox2) {
|
|
5550
|
+
const outRings = [];
|
|
5551
|
+
for (const ring of rings) {
|
|
5552
|
+
const clipped = polygonclip(ring, bbox2);
|
|
5553
|
+
if (clipped.length > 0) {
|
|
5554
|
+
if (clipped[0][0] !== clipped[clipped.length - 1][0] || clipped[0][1] !== clipped[clipped.length - 1][1]) {
|
|
5555
|
+
clipped.push(clipped[0]);
|
|
5556
|
+
}
|
|
5557
|
+
if (clipped.length >= 4) {
|
|
5558
|
+
outRings.push(clipped);
|
|
5559
|
+
}
|
|
5560
|
+
}
|
|
5561
|
+
}
|
|
5562
|
+
return outRings;
|
|
5563
|
+
}
|
|
5564
|
+
var turf_bbox_clip_default = bboxClip;
|
|
5565
|
+
|
|
5566
|
+
// src/filters/tileFeaturesSpatialIndex.ts
|
|
5567
|
+
var import_h3_js = require("h3-js");
|
|
5623
5568
|
function tileFeaturesSpatialIndex({
|
|
5624
5569
|
tiles,
|
|
5625
5570
|
spatialFilter,
|
|
@@ -5628,50 +5573,58 @@ function tileFeaturesSpatialIndex({
|
|
|
5628
5573
|
}) {
|
|
5629
5574
|
const map = /* @__PURE__ */ new Map();
|
|
5630
5575
|
const spatialIndex = getSpatialIndex(spatialDataType);
|
|
5631
|
-
const
|
|
5576
|
+
const resolution = getResolution(tiles, spatialIndex);
|
|
5632
5577
|
const spatialIndexIDName = spatialDataColumn ? spatialDataColumn : spatialIndex;
|
|
5633
|
-
if (!
|
|
5578
|
+
if (!resolution) {
|
|
5579
|
+
return [];
|
|
5580
|
+
}
|
|
5581
|
+
const cells = getCellsCoverGeometry(spatialFilter, spatialIndex, resolution);
|
|
5582
|
+
if (!cells?.length) {
|
|
5634
5583
|
return [];
|
|
5635
5584
|
}
|
|
5585
|
+
const cellsSet = new Set(cells);
|
|
5636
5586
|
for (const tile of tiles) {
|
|
5637
5587
|
if (tile.isVisible === false || !tile.data) {
|
|
5638
5588
|
continue;
|
|
5639
5589
|
}
|
|
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;
|
|
5651
5590
|
tile.data.forEach((d) => {
|
|
5652
|
-
if (
|
|
5591
|
+
if (cellsSet.has(d.id)) {
|
|
5653
5592
|
map.set(d.id, { ...d.properties, [spatialIndexIDName]: d.id });
|
|
5654
5593
|
}
|
|
5655
5594
|
});
|
|
5656
5595
|
}
|
|
5657
5596
|
return Array.from(map.values());
|
|
5658
5597
|
}
|
|
5659
|
-
function getTileIndex(tile, spatialIndex) {
|
|
5660
|
-
if (spatialIndex === "quadbin" /* QUADBIN */) {
|
|
5661
|
-
return tile.index.q;
|
|
5662
|
-
}
|
|
5663
|
-
return tile.id;
|
|
5664
|
-
}
|
|
5665
5598
|
function getResolution(tiles, spatialIndex) {
|
|
5666
5599
|
const data = tiles.find((tile) => tile.data?.length)?.data;
|
|
5667
5600
|
if (!data) {
|
|
5668
5601
|
return;
|
|
5669
5602
|
}
|
|
5670
5603
|
if (spatialIndex === "quadbin" /* QUADBIN */) {
|
|
5671
|
-
return Number((0,
|
|
5604
|
+
return Number((0, import_quadbin.getResolution)(data[0].id));
|
|
5605
|
+
}
|
|
5606
|
+
if (spatialIndex === "h3" /* H3 */) {
|
|
5607
|
+
return (0, import_h3_js.getResolution)(data[0].id);
|
|
5608
|
+
}
|
|
5609
|
+
}
|
|
5610
|
+
var bboxWest = [-180, -90, 0, 90];
|
|
5611
|
+
var bboxEast = [0, -90, 180, 90];
|
|
5612
|
+
function getCellsCoverGeometry(geometry, spatialIndex, resolution) {
|
|
5613
|
+
if (spatialIndex === "quadbin" /* QUADBIN */) {
|
|
5614
|
+
return (0, import_quadbin.geometryToCells)(geometry, resolution);
|
|
5672
5615
|
}
|
|
5673
5616
|
if (spatialIndex === "h3" /* H3 */) {
|
|
5674
|
-
return (0,
|
|
5617
|
+
return (0, import_h3_js.polygonToCells)(
|
|
5618
|
+
turf_bbox_clip_default(geometry, bboxWest).geometry.coordinates,
|
|
5619
|
+
resolution,
|
|
5620
|
+
true
|
|
5621
|
+
).concat(
|
|
5622
|
+
(0, import_h3_js.polygonToCells)(
|
|
5623
|
+
turf_bbox_clip_default(geometry, bboxEast).geometry.coordinates,
|
|
5624
|
+
resolution,
|
|
5625
|
+
true
|
|
5626
|
+
)
|
|
5627
|
+
);
|
|
5675
5628
|
}
|
|
5676
5629
|
}
|
|
5677
5630
|
function getSpatialIndex(spatialDataType) {
|
|
@@ -5699,7 +5652,7 @@ var DEFAULT_AGGREGATION_EXP = `1 AS ${DEFAULT_AGGREGATION_EXP_ALIAS}`;
|
|
|
5699
5652
|
|
|
5700
5653
|
// src/filters/tileFeaturesRaster.ts
|
|
5701
5654
|
init_cjs_shims();
|
|
5702
|
-
var
|
|
5655
|
+
var import_quadbin2 = require("quadbin");
|
|
5703
5656
|
function tileFeaturesRaster({
|
|
5704
5657
|
tiles,
|
|
5705
5658
|
...options
|
|
@@ -5710,21 +5663,21 @@ function tileFeaturesRaster({
|
|
|
5710
5663
|
}
|
|
5711
5664
|
tiles = tiles.filter(isRasterTileVisible);
|
|
5712
5665
|
if (tiles.length === 0) return [];
|
|
5713
|
-
const tileResolution = (0,
|
|
5666
|
+
const tileResolution = (0, import_quadbin2.getResolution)(tiles[0].index.q);
|
|
5714
5667
|
const tileBlockSize = tiles[0].data.blockSize;
|
|
5715
5668
|
const cellResolution = tileResolution + BigInt(Math.log2(tileBlockSize));
|
|
5716
5669
|
const data = /* @__PURE__ */ new Map();
|
|
5717
5670
|
for (const tile of tiles) {
|
|
5718
5671
|
const parent = tile.index.q;
|
|
5719
|
-
const
|
|
5720
|
-
|
|
5721
|
-
|
|
5722
|
-
options.spatialFilter
|
|
5672
|
+
const tilePolygon = (0, import_quadbin2.cellToBoundary)(parent);
|
|
5673
|
+
const tileFilter = turf_intersect_default(
|
|
5674
|
+
featureCollection([feature(tilePolygon), feature(options.spatialFilter)])
|
|
5723
5675
|
);
|
|
5724
|
-
|
|
5676
|
+
const needsFilter = tileFilter ? !turf_boolean_within_default(tilePolygon, options.spatialFilter) : false;
|
|
5677
|
+
const tileFilterCells = needsFilter ? new Set((0, import_quadbin2.geometryToCells)(tileFilter.geometry, cellResolution)) : null;
|
|
5725
5678
|
const tileSortedCells = cellToChildrenSorted(parent, cellResolution);
|
|
5726
5679
|
for (let i = 0; i < tileSortedCells.length; i++) {
|
|
5727
|
-
if (
|
|
5680
|
+
if (needsFilter && !tileFilterCells.has(tileSortedCells[i])) {
|
|
5728
5681
|
continue;
|
|
5729
5682
|
}
|
|
5730
5683
|
const cellData = {};
|
|
@@ -5751,10 +5704,10 @@ function isRasterTileVisible(tile) {
|
|
|
5751
5704
|
return !!(tile.isVisible && tile.data?.cells?.numericProps);
|
|
5752
5705
|
}
|
|
5753
5706
|
function cellToChildrenSorted(parent, resolution) {
|
|
5754
|
-
return (0,
|
|
5707
|
+
return (0, import_quadbin2.cellToChildren)(parent, resolution).sort(
|
|
5755
5708
|
(cellA, cellB) => {
|
|
5756
|
-
const tileA = (0,
|
|
5757
|
-
const tileB = (0,
|
|
5709
|
+
const tileA = (0, import_quadbin2.cellToTile)(cellA);
|
|
5710
|
+
const tileB = (0, import_quadbin2.cellToTile)(cellB);
|
|
5758
5711
|
if (tileA.y !== tileB.y) {
|
|
5759
5712
|
return tileA.y > tileB.y ? 1 : -1;
|
|
5760
5713
|
}
|
|
@@ -6558,6 +6511,10 @@ function getApplicableFilters(owner, filters) {
|
|
|
6558
6511
|
return applicableFilters;
|
|
6559
6512
|
}
|
|
6560
6513
|
|
|
6514
|
+
// src/widget-sources/constants.ts
|
|
6515
|
+
init_cjs_shims();
|
|
6516
|
+
var OTHERS_CATEGORY_NAME = "_carto_others";
|
|
6517
|
+
|
|
6561
6518
|
// src/widget-sources/widget-remote-source.ts
|
|
6562
6519
|
var WidgetRemoteSource = class extends WidgetSource {
|
|
6563
6520
|
_getModelSource(filters, filterOwner) {
|
|
@@ -6581,13 +6538,21 @@ var WidgetRemoteSource = class extends WidgetSource {
|
|
|
6581
6538
|
filterOwner,
|
|
6582
6539
|
spatialFilter,
|
|
6583
6540
|
spatialFiltersMode,
|
|
6541
|
+
rawResult,
|
|
6584
6542
|
...params
|
|
6585
6543
|
} = options;
|
|
6586
|
-
const {
|
|
6544
|
+
const {
|
|
6545
|
+
column,
|
|
6546
|
+
operation: operation2,
|
|
6547
|
+
operationColumn,
|
|
6548
|
+
operationExp,
|
|
6549
|
+
othersThreshold,
|
|
6550
|
+
orderBy
|
|
6551
|
+
} = params;
|
|
6587
6552
|
if (operation2 === AggregationTypes.Custom) {
|
|
6588
6553
|
assert2(operationExp, "operationExp is required for custom operation");
|
|
6589
6554
|
}
|
|
6590
|
-
|
|
6555
|
+
const result = await executeModel({
|
|
6591
6556
|
model: "category",
|
|
6592
6557
|
source: {
|
|
6593
6558
|
...this.getModelSource(filters, filterOwner),
|
|
@@ -6598,10 +6563,23 @@ var WidgetRemoteSource = class extends WidgetSource {
|
|
|
6598
6563
|
column,
|
|
6599
6564
|
operation: operation2,
|
|
6600
6565
|
operationExp,
|
|
6601
|
-
operationColumn: operationColumn || column
|
|
6566
|
+
operationColumn: operationColumn || column,
|
|
6567
|
+
othersThreshold,
|
|
6568
|
+
orderBy
|
|
6602
6569
|
},
|
|
6603
6570
|
opts: { signal, headers: this.props.headers }
|
|
6604
|
-
})
|
|
6571
|
+
});
|
|
6572
|
+
const normalizedRows = normalizeObjectKeys(result.rows || []);
|
|
6573
|
+
if (rawResult) {
|
|
6574
|
+
return result;
|
|
6575
|
+
}
|
|
6576
|
+
if (!othersThreshold) {
|
|
6577
|
+
return normalizedRows;
|
|
6578
|
+
}
|
|
6579
|
+
return [
|
|
6580
|
+
...normalizedRows,
|
|
6581
|
+
{ name: OTHERS_CATEGORY_NAME, value: result?.metadata?.others }
|
|
6582
|
+
];
|
|
6605
6583
|
}
|
|
6606
6584
|
async getFeatures(options) {
|
|
6607
6585
|
const {
|
|
@@ -7006,10 +6984,12 @@ function groupValuesByColumn({
|
|
|
7006
6984
|
valuesColumns,
|
|
7007
6985
|
joinOperation,
|
|
7008
6986
|
keysColumn,
|
|
7009
|
-
operation: operation2
|
|
6987
|
+
operation: operation2,
|
|
6988
|
+
othersThreshold,
|
|
6989
|
+
orderBy = "frequency_desc"
|
|
7010
6990
|
}) {
|
|
7011
6991
|
if (Array.isArray(data) && data.length === 0) {
|
|
7012
|
-
return null;
|
|
6992
|
+
return { rows: null };
|
|
7013
6993
|
}
|
|
7014
6994
|
const groups = data.reduce((accumulator, item) => {
|
|
7015
6995
|
const group2 = item[keysColumn];
|
|
@@ -7024,13 +7004,44 @@ function groupValuesByColumn({
|
|
|
7024
7004
|
return accumulator;
|
|
7025
7005
|
}, /* @__PURE__ */ new Map());
|
|
7026
7006
|
const targetOperation = aggregationFunctions[operation2];
|
|
7027
|
-
if (targetOperation) {
|
|
7028
|
-
return
|
|
7029
|
-
|
|
7030
|
-
|
|
7031
|
-
|
|
7007
|
+
if (!targetOperation) {
|
|
7008
|
+
return { rows: [] };
|
|
7009
|
+
}
|
|
7010
|
+
const allCategories = Array.from(groups).map(([name, value]) => ({
|
|
7011
|
+
name,
|
|
7012
|
+
value: targetOperation(value)
|
|
7013
|
+
})).sort(getSorter(orderBy));
|
|
7014
|
+
if (othersThreshold && allCategories.length > othersThreshold) {
|
|
7015
|
+
const otherValue = allCategories.slice(othersThreshold).flatMap(({ name }) => groups.get(name));
|
|
7016
|
+
allCategories.push({
|
|
7017
|
+
name: OTHERS_CATEGORY_NAME,
|
|
7018
|
+
value: targetOperation(otherValue)
|
|
7019
|
+
});
|
|
7020
|
+
return {
|
|
7021
|
+
rows: allCategories,
|
|
7022
|
+
metadata: {
|
|
7023
|
+
others: targetOperation(otherValue)
|
|
7024
|
+
}
|
|
7025
|
+
};
|
|
7032
7026
|
}
|
|
7033
|
-
return
|
|
7027
|
+
return {
|
|
7028
|
+
rows: allCategories
|
|
7029
|
+
};
|
|
7030
|
+
}
|
|
7031
|
+
function getSorter(orderBy) {
|
|
7032
|
+
switch (orderBy) {
|
|
7033
|
+
case "frequency_asc":
|
|
7034
|
+
return (a, b) => a.value - b.value || localeCompare(a.name, b.name);
|
|
7035
|
+
case "frequency_desc":
|
|
7036
|
+
return (a, b) => b.value - a.value || localeCompare(a.name, b.name);
|
|
7037
|
+
case "alphabetical_asc":
|
|
7038
|
+
return (a, b) => localeCompare(a.name, b.name) || b.value - a.value;
|
|
7039
|
+
case "alphabetical_desc":
|
|
7040
|
+
return (a, b) => localeCompare(b.name, a.name) || b.value - a.value;
|
|
7041
|
+
}
|
|
7042
|
+
}
|
|
7043
|
+
function localeCompare(a, b) {
|
|
7044
|
+
return (a ?? "null").localeCompare(b ?? "null");
|
|
7034
7045
|
}
|
|
7035
7046
|
|
|
7036
7047
|
// src/operations/groupByDate.ts
|
|
@@ -7515,7 +7526,7 @@ var WidgetTilesetSourceImpl = class extends WidgetSource {
|
|
|
7515
7526
|
}
|
|
7516
7527
|
_extractTileFeatures(spatialFilter) {
|
|
7517
7528
|
const prevInputs = this._tileFeatureExtractPreviousInputs;
|
|
7518
|
-
if (this._features.length &&
|
|
7529
|
+
if (this._features.length && prevInputs.spatialFilter && booleanEqual(prevInputs.spatialFilter, spatialFilter)) {
|
|
7519
7530
|
return;
|
|
7520
7531
|
}
|
|
7521
7532
|
this._features = tileFeatures({
|
|
@@ -7604,7 +7615,10 @@ var WidgetTilesetSourceImpl = class extends WidgetSource {
|
|
|
7604
7615
|
joinOperation,
|
|
7605
7616
|
filters,
|
|
7606
7617
|
filterOwner,
|
|
7607
|
-
spatialFilter
|
|
7618
|
+
spatialFilter,
|
|
7619
|
+
othersThreshold,
|
|
7620
|
+
orderBy = "frequency_desc",
|
|
7621
|
+
rawResult
|
|
7608
7622
|
}) {
|
|
7609
7623
|
const filteredFeatures = this._getFilteredFeatures(
|
|
7610
7624
|
spatialFilter,
|
|
@@ -7615,14 +7629,25 @@ var WidgetTilesetSourceImpl = class extends WidgetSource {
|
|
|
7615
7629
|
return [];
|
|
7616
7630
|
}
|
|
7617
7631
|
assertColumn(this._features, column, operationColumn);
|
|
7618
|
-
const
|
|
7632
|
+
const result = groupValuesByColumn({
|
|
7619
7633
|
data: filteredFeatures,
|
|
7620
7634
|
valuesColumns: normalizeColumns(operationColumn || column),
|
|
7621
7635
|
joinOperation,
|
|
7622
7636
|
keysColumn: column,
|
|
7623
|
-
operation: operation2
|
|
7637
|
+
operation: operation2,
|
|
7638
|
+
othersThreshold,
|
|
7639
|
+
orderBy
|
|
7624
7640
|
});
|
|
7625
|
-
|
|
7641
|
+
if (rawResult) {
|
|
7642
|
+
return result;
|
|
7643
|
+
}
|
|
7644
|
+
if (!othersThreshold) {
|
|
7645
|
+
return result?.rows || [];
|
|
7646
|
+
}
|
|
7647
|
+
return [
|
|
7648
|
+
...result?.rows || [],
|
|
7649
|
+
{ name: OTHERS_CATEGORY_NAME, value: result?.metadata?.others }
|
|
7650
|
+
];
|
|
7626
7651
|
}
|
|
7627
7652
|
async getScatter({
|
|
7628
7653
|
xAxisColumn,
|
|
@@ -7755,6 +7780,7 @@ var WidgetTilesetSourceImpl = class extends WidgetSource {
|
|
|
7755
7780
|
* INTERNAL
|
|
7756
7781
|
*/
|
|
7757
7782
|
_getFilteredFeatures(spatialFilter, filters, filterOwner) {
|
|
7783
|
+
assert2(spatialFilter, "spatialFilter required for tilesets");
|
|
7758
7784
|
this._extractTileFeatures(spatialFilter);
|
|
7759
7785
|
return applyFilters(
|
|
7760
7786
|
this._features,
|
|
@@ -7778,11 +7804,6 @@ function assertColumn(features, ...columnArgs) {
|
|
|
7778
7804
|
function normalizeColumns(columns) {
|
|
7779
7805
|
return Array.isArray(columns) ? columns : typeof columns === "string" ? [columns] : [];
|
|
7780
7806
|
}
|
|
7781
|
-
function spatialFilterEquals(a, b) {
|
|
7782
|
-
if (a === b) return true;
|
|
7783
|
-
if (!a || !b) return false;
|
|
7784
|
-
return booleanEqual(a, b);
|
|
7785
|
-
}
|
|
7786
7807
|
|
|
7787
7808
|
// src/widget-sources/widget-tileset-source.ts
|
|
7788
7809
|
var WidgetTilesetSource = class extends WidgetSource {
|
|
@@ -10415,6 +10436,7 @@ function hashBuckets(initialCount) {
|
|
|
10415
10436
|
FEATURE_GEOM_PROPERTY,
|
|
10416
10437
|
FilterType,
|
|
10417
10438
|
OPACITY_MAP,
|
|
10439
|
+
OTHERS_CATEGORY_NAME,
|
|
10418
10440
|
Provider,
|
|
10419
10441
|
SOURCE_DEFAULTS,
|
|
10420
10442
|
SchemaFieldType,
|
|
@@ -10465,6 +10487,7 @@ function hashBuckets(initialCount) {
|
|
|
10465
10487
|
getLayerProps,
|
|
10466
10488
|
getMaxMarkerSize,
|
|
10467
10489
|
getSizeAccessor,
|
|
10490
|
+
getSorter,
|
|
10468
10491
|
getSpatialIndexFromGeoColumn,
|
|
10469
10492
|
getTextAccessor,
|
|
10470
10493
|
groupValuesByColumn,
|