@maplibre/geojson-vt 6.0.4 → 6.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/clip.d.ts.map +1 -1
- package/dist/convert.d.ts.map +1 -1
- package/dist/deconvert.d.ts +1 -1
- package/dist/deconvert.d.ts.map +1 -1
- package/dist/definitions.d.ts +12 -5
- package/dist/definitions.d.ts.map +1 -1
- package/dist/difference.d.ts +1 -1
- package/dist/difference.d.ts.map +1 -1
- package/dist/feature.d.ts +2 -1
- package/dist/feature.d.ts.map +1 -1
- package/dist/geojson-vt-dev.js +102 -99
- package/dist/geojson-vt.js +1 -1
- package/dist/geojson-vt.mjs +102 -99
- package/dist/geojson-vt.mjs.map +1 -1
- package/dist/geojsonvt.d.ts +0 -15
- package/dist/geojsonvt.d.ts.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/tile-index.d.ts +1 -2
- package/dist/tile-index.d.ts.map +1 -1
- package/dist/tile-index.test.d.ts +2 -0
- package/dist/tile-index.test.d.ts.map +1 -0
- package/dist/tile.d.ts.map +1 -1
- package/dist/wrap.d.ts.map +1 -1
- package/package.json +9 -9
- package/src/clip.test.ts +21 -22
- package/src/clip.ts +37 -35
- package/src/convert.ts +17 -16
- package/src/deconvert.test.ts +7 -7
- package/src/deconvert.ts +8 -4
- package/src/definitions.ts +7 -5
- package/src/difference.test.ts +2 -2
- package/src/difference.ts +16 -18
- package/src/feature.ts +16 -6
- package/src/geojsonvt.ts +0 -26
- package/src/index.ts +3 -2
- package/src/tile-index.test.ts +270 -0
- package/src/tile-index.ts +5 -5
- package/src/tile.ts +6 -6
- package/src/wrap.ts +38 -18
package/dist/clip.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"clip.d.ts","sourceRoot":"","sources":["../src/clip.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,wBAAwB,EAAyN,gBAAgB,
|
|
1
|
+
{"version":3,"file":"clip.d.ts","sourceRoot":"","sources":["../src/clip.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,wBAAwB,EAAyN,gBAAgB,EAA+B,MAAM,eAAe,CAAC;AAEpU,0BAAkB,QAAQ;IACtB,CAAC,IAAI;IACL,CAAC,IAAI;CACR;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,IAAI,CAAC,QAAQ,EAAE,wBAAwB,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,gBAAgB,GAAG,wBAAwB,EAAE,GAAG,IAAI,CA2DlN"}
|
package/dist/convert.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"convert.d.ts","sourceRoot":"","sources":["../src/convert.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAC,wBAAwB,EAAE,gBAAgB,
|
|
1
|
+
{"version":3,"file":"convert.d.ts","sourceRoot":"","sources":["../src/convert.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAC,wBAAwB,EAAE,gBAAgB,EAAa,MAAM,eAAe,CAAC;AAE1F;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,OAAO,CAAC,OAAO,EAAE,OAAO,EAAE,gBAAgB,GAAG,wBAAwB,EAAE,CAiB9G;AA8JD;;GAEG;AACH,wBAAgB,QAAQ,CAAC,CAAC,EAAE,MAAM,UAEjC;AAED;;GAEG;AACH,wBAAgB,QAAQ,CAAC,CAAC,EAAE,MAAM,UAIjC"}
|
package/dist/deconvert.d.ts
CHANGED
|
@@ -7,7 +7,7 @@ export declare function convertToGeoJSON(source: GeoJSONVTInternalFeature[]): Ge
|
|
|
7
7
|
* Converts a single internal feature to GeoJSON format.
|
|
8
8
|
*/
|
|
9
9
|
export declare function featureToGeoJSON(feature: GeoJSONVTInternalFeature): GeoJSON.Feature;
|
|
10
|
-
export declare function unprojectPoints(coords: number[]): GeoJSON.Position[];
|
|
10
|
+
export declare function unprojectPoints(coords: number[] | Float64Array): GeoJSON.Position[];
|
|
11
11
|
/**
|
|
12
12
|
* Convert spherical mercator in [0..1] range to longitude
|
|
13
13
|
*/
|
package/dist/deconvert.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deconvert.d.ts","sourceRoot":"","sources":["../src/deconvert.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,wBAAwB,EAAC,MAAM,eAAe,CAAC;AAE5D;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,wBAAwB,EAAE,GAAG,OAAO,CAAC,OAAO,CAOpF;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,wBAAwB,GAAG,OAAO,CAAC,OAAO,CAWnF;
|
|
1
|
+
{"version":3,"file":"deconvert.d.ts","sourceRoot":"","sources":["../src/deconvert.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,wBAAwB,EAAC,MAAM,eAAe,CAAC;AAE5D;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,wBAAwB,EAAE,GAAG,OAAO,CAAC,OAAO,CAOpF;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,wBAAwB,GAAG,OAAO,CAAC,OAAO,CAWnF;AAwCD,wBAAgB,eAAe,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,YAAY,GAAG,OAAO,CAAC,QAAQ,EAAE,CAQnF;AAMD;;GAEG;AACH,wBAAgB,UAAU,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAE5C;AAED;;GAEG;AACH,wBAAgB,UAAU,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAG5C"}
|
package/dist/definitions.d.ts
CHANGED
|
@@ -76,7 +76,14 @@ export type GeoJSONToTileOptions = GeoJSONVTOptions & {
|
|
|
76
76
|
*/
|
|
77
77
|
clip?: boolean;
|
|
78
78
|
};
|
|
79
|
-
export type
|
|
79
|
+
export type SliceArray = {
|
|
80
|
+
points: number[];
|
|
81
|
+
start?: number;
|
|
82
|
+
end?: number;
|
|
83
|
+
size?: number;
|
|
84
|
+
};
|
|
85
|
+
export type SliceFixedArray = {
|
|
86
|
+
points: number[] | Float64Array;
|
|
80
87
|
start?: number;
|
|
81
88
|
end?: number;
|
|
82
89
|
size?: number;
|
|
@@ -99,19 +106,19 @@ export type GeoJSONVTInternalMultiPointFeature = PartialGeoJSONVTFeature & {
|
|
|
99
106
|
};
|
|
100
107
|
export type GeoJSONVTInternalLineStringFeature = PartialGeoJSONVTFeature & {
|
|
101
108
|
type: 'LineString';
|
|
102
|
-
geometry:
|
|
109
|
+
geometry: SliceFixedArray;
|
|
103
110
|
};
|
|
104
111
|
export type GeoJSONVTInternalMultiLineStringFeature = PartialGeoJSONVTFeature & {
|
|
105
112
|
type: 'MultiLineString';
|
|
106
|
-
geometry:
|
|
113
|
+
geometry: SliceFixedArray[];
|
|
107
114
|
};
|
|
108
115
|
export type GeoJSONVTInternalPolygonFeature = PartialGeoJSONVTFeature & {
|
|
109
116
|
type: 'Polygon';
|
|
110
|
-
geometry:
|
|
117
|
+
geometry: SliceFixedArray[];
|
|
111
118
|
};
|
|
112
119
|
export type GeoJSONVTInternalMultiPolygonFeature = PartialGeoJSONVTFeature & {
|
|
113
120
|
type: 'MultiPolygon';
|
|
114
|
-
geometry:
|
|
121
|
+
geometry: SliceFixedArray[][];
|
|
115
122
|
};
|
|
116
123
|
export type GeoJSONVTInternalFeature = GeoJSONVTInternalPointFeature | GeoJSONVTInternalMultiPointFeature | GeoJSONVTInternalLineStringFeature | GeoJSONVTInternalMultiLineStringFeature | GeoJSONVTInternalPolygonFeature | GeoJSONVTInternalMultiPolygonFeature;
|
|
117
124
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"definitions.d.ts","sourceRoot":"","sources":["../src/definitions.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,gBAAgB,GAAG;IAC3B;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;;OAGG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB;;;OAGG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;;OAGG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B;;;OAGG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB;;;OAGG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;;OAGG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB;;;OAGG;IACH,cAAc,CAAC,EAAE,mBAAmB,CAAC;CACxC,CAAC;AAEF,MAAM,MAAM,oBAAoB,GAAG,gBAAgB,GAAG;IAClD;;;OAGG;IACH,IAAI,CAAC,EAAE,OAAO,CAAC;IACf;;;OAGG;IACH,IAAI,CAAC,EAAE,OAAO,CAAC;CAClB,CAAC;AAEF,MAAM,MAAM,
|
|
1
|
+
{"version":3,"file":"definitions.d.ts","sourceRoot":"","sources":["../src/definitions.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,gBAAgB,GAAG;IAC3B;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;;OAGG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB;;;OAGG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB;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C,OAAO,CAAC,KAAK,CAAC,EAAE,GAAG,IAAI,CAAA;IACtG,OAAO,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,aAAa,GAAG,IAAI,CAAA;CACjE;AAED,MAAM,MAAM,mBAAmB,GAAG;IAC9B;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;;OAGG;IACH,GAAG,CAAC,EAAE,OAAO,CAAC;IACd;;;OAGG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB;;;OAGG;IACH,MAAM,CAAC,EAAE,CAAC,CAAC,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,IAAI,CAAC,GAAG,IAAI,CAAC;IACjG;;;OAGG;IACH,GAAG,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,CAAC,iBAAiB,KAAK,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACvE,CAAC"}
|
package/dist/difference.d.ts
CHANGED
|
@@ -69,6 +69,6 @@ export declare function applySourceDiff(source: GeoJSONVTInternalFeature[], data
|
|
|
69
69
|
/**
|
|
70
70
|
* Convert a GeoJSON Source Diff to an idempotent hashed representation using Sets and Maps
|
|
71
71
|
*/
|
|
72
|
-
export declare function diffToHashed(diff: GeoJSONVTSourceDiff): HashedGeoJSONVTSourceDiff;
|
|
72
|
+
export declare function diffToHashed(diff: GeoJSONVTSourceDiff, options: GeoJSONVTOptions): HashedGeoJSONVTSourceDiff;
|
|
73
73
|
export {};
|
|
74
74
|
//# sourceMappingURL=difference.d.ts.map
|
package/dist/difference.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"difference.d.ts","sourceRoot":"","sources":["../src/difference.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,wBAAwB,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAEhF,MAAM,MAAM,mBAAmB,GAAG;IAC9B;;OAEG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB;;OAEG;IACH,MAAM,CAAC,EAAE,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,CAAC;IAC7B;;OAEG;IACH,GAAG,CAAC,EAAE,OAAO,CAAC,OAAO,EAAE,CAAC;IACxB;;OAEG;IACH,MAAM,CAAC,EAAE,oBAAoB,EAAE,CAAC;CACnC,CAAC;AAEF,MAAM,MAAM,oBAAoB,GAAG;IAC/B;;OAEG;IACH,EAAE,EAAE,MAAM,GAAG,MAAM,CAAC;IACpB;;OAEG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC,QAAQ,CAAC;IAC/B;;OAEG;IACH,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B;;OAEG;IACH,gBAAgB,CAAC,EAAE,MAAM,EAAE,CAAC;IAC5B;;OAEG;IACH,qBAAqB,CAAC,EAAE;QACpB,GAAG,EAAE,MAAM,CAAC;QACZ,KAAK,EAAE,OAAO,CAAC;KAClB,EAAE,CAAC;CACP,CAAC;AAEF,MAAM,MAAM,qBAAqB,GAAG;IAChC;;OAEG;IACH,QAAQ,EAAE,wBAAwB,EAAE,CAAC;IACrC;;OAEG;IACH,MAAM,EAAE,wBAAwB,EAAE,CAAC;CACtC,CAAC;AAEF,KAAK,yBAAyB,GAAG;IAC7B,SAAS,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IAChC,MAAM,EAAE,GAAG,CAAC,MAAM,GAAG,MAAM,CAAC,C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AAE,CAAC;IACrC;;OAEG;IACH,MAAM,EAAE,wBAAwB,EAAE,CAAC;CACtC,CAAC;AAEF,KAAK,yBAAyB,GAAG;IAC7B,SAAS,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IAChC,MAAM,EAAE,GAAG,CAAC,MAAM,GAAG,MAAM,CAAC,CAAC;IAC7B,GAAG,EAAE,GAAG,CAAC,MAAM,GAAG,MAAM,GAAG,SAAS,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC;IACvD,MAAM,EAAE,GAAG,CAAC,MAAM,GAAG,MAAM,EAAE,oBAAoB,CAAC,CAAC;CACtD,CAAC;AAEF;;;;;;GAMG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,wBAAwB,EAAE,EAAE,QAAQ,EAAE,mBAAmB,EAAE,OAAO,EAAE,gBAAgB,GAAG,qBAAqB,CA2DnJ;AAqED;;GAEG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,mBAAmB,EAAE,OAAO,EAAE,gBAAgB,GAAG,yBAAyB,CAe5G"}
|
package/dist/feature.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { GeoJSONVTInternalFeature, GeoJSONVTInternalLineStringFeature, GeoJSONVTInternalMultiLineStringFeature, GeoJSONVTInternalMultiPointFeature, GeoJSONVTInternalMultiPolygonFeature, GeoJSONVTInternalPointFeature, GeoJSONVTInternalPolygonFeature } from "./definitions";
|
|
1
|
+
import type { GeoJSONVTInternalFeature, GeoJSONVTInternalLineStringFeature, GeoJSONVTInternalMultiLineStringFeature, GeoJSONVTInternalMultiPointFeature, GeoJSONVTInternalMultiPolygonFeature, GeoJSONVTInternalPointFeature, GeoJSONVTInternalPolygonFeature, SliceArray } from "./definitions";
|
|
2
2
|
type FeatureTypeMap = {
|
|
3
3
|
Point: GeoJSONVTInternalPointFeature["geometry"];
|
|
4
4
|
MultiPoint: GeoJSONVTInternalMultiPointFeature["geometry"];
|
|
@@ -16,5 +16,6 @@ type FeatureTypeMap = {
|
|
|
16
16
|
* @returns the created feature
|
|
17
17
|
*/
|
|
18
18
|
export declare function createFeature<T extends GeoJSONVTInternalFeature["type"]>(id: number | string | undefined, type: T, geom: FeatureTypeMap[T], tags: GeoJSON.GeoJsonProperties): GeoJSONVTInternalFeature;
|
|
19
|
+
export declare function optimizeLineMemory(line: SliceArray): void;
|
|
19
20
|
export {};
|
|
20
21
|
//# sourceMappingURL=feature.d.ts.map
|
package/dist/feature.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"feature.d.ts","sourceRoot":"","sources":["../src/feature.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,wBAAwB,EAAE,kCAAkC,EAAE,uCAAuC,EAAE,kCAAkC,EAAE,oCAAoC,EAAE,6BAA6B,EAAE,+BAA+B,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"feature.d.ts","sourceRoot":"","sources":["../src/feature.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,wBAAwB,EAAE,kCAAkC,EAAE,uCAAuC,EAAE,kCAAkC,EAAE,oCAAoC,EAAE,6BAA6B,EAAE,+BAA+B,EAAE,UAAU,EAAmB,MAAM,eAAe,CAAC;AAElT,KAAK,cAAc,GAAG;IAClB,KAAK,EAAE,6BAA6B,CAAC,UAAU,CAAC,CAAC;IACjD,UAAU,EAAE,kCAAkC,CAAC,UAAU,CAAC,CAAC;IAC3D,UAAU,EAAE,kCAAkC,CAAC,UAAU,CAAC,CAAC;IAC3D,eAAe,EAAE,uCAAuC,CAAC,UAAU,CAAC,CAAC;IACrE,OAAO,EAAE,+BAA+B,CAAC,UAAU,CAAC,CAAC;IACrD,YAAY,EAAE,oCAAoC,CAAC,UAAU,CAAC,CAAC;CAClE,CAAC;AAEF;;;;;;;GAOG;AACH,wBAAgB,aAAa,CAAC,CAAC,SAAS,wBAAwB,CAAC,MAAM,CAAC,EAAE,EAAE,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,EAAE,IAAI,EAAE,CAAC,EAAE,IAAI,EAAE,cAAc,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,OAAO,CAAC,iBAAiB,GAAG,wBAAwB,CA6CtM;AAED,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,UAAU,QAKlD"}
|
package/dist/geojson-vt-dev.js
CHANGED
|
@@ -99,27 +99,35 @@ function createFeature(id, type, geom, tags) {
|
|
|
99
99
|
switch (data.type) {
|
|
100
100
|
case 'Point':
|
|
101
101
|
case 'MultiPoint':
|
|
102
|
-
case 'LineString':
|
|
103
102
|
calcLineBBox(feature, data.geom);
|
|
104
103
|
break;
|
|
104
|
+
case 'LineString':
|
|
105
|
+
calcLineBBox(feature, data.geom.points);
|
|
106
|
+
break;
|
|
105
107
|
case 'Polygon':
|
|
106
108
|
// the outer ring (ie [0]) contains all inner rings
|
|
107
|
-
calcLineBBox(feature, data.geom[0]);
|
|
109
|
+
calcLineBBox(feature, data.geom[0].points);
|
|
108
110
|
break;
|
|
109
111
|
case 'MultiLineString':
|
|
110
112
|
for (const line of data.geom) {
|
|
111
|
-
calcLineBBox(feature, line);
|
|
113
|
+
calcLineBBox(feature, line.points);
|
|
112
114
|
}
|
|
113
115
|
break;
|
|
114
116
|
case 'MultiPolygon':
|
|
115
117
|
for (const polygon of data.geom) {
|
|
116
118
|
// the outer ring (ie [0]) contains all inner rings
|
|
117
|
-
calcLineBBox(feature, polygon[0]);
|
|
119
|
+
calcLineBBox(feature, polygon[0].points);
|
|
118
120
|
}
|
|
119
121
|
break;
|
|
120
122
|
}
|
|
121
123
|
return feature;
|
|
122
124
|
}
|
|
125
|
+
function optimizeLineMemory(line) {
|
|
126
|
+
const lineImmutable = line;
|
|
127
|
+
if (line.points.length > 64) {
|
|
128
|
+
lineImmutable.points = new Float64Array(line.points);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
123
131
|
function calcLineBBox(feature, geom) {
|
|
124
132
|
for (let i = 0; i < geom.length; i += 3) {
|
|
125
133
|
feature.minX = Math.min(feature.minX, geom[i]);
|
|
@@ -217,7 +225,7 @@ function convertMultiPointFeature(features, id, geom, properties) {
|
|
|
217
225
|
features.push(createFeature(id, 'MultiPoint', out, properties));
|
|
218
226
|
}
|
|
219
227
|
function convertLineStringFeature(features, id, geom, tolerance, properties) {
|
|
220
|
-
const out = [];
|
|
228
|
+
const out = { points: [] };
|
|
221
229
|
convertLine(geom.coordinates, out, tolerance, false);
|
|
222
230
|
features.push(createFeature(id, 'LineString', out, properties));
|
|
223
231
|
}
|
|
@@ -225,7 +233,7 @@ function convertMultiLineStringFeature(features, id, geom, tolerance, options, p
|
|
|
225
233
|
if (options.lineMetrics) {
|
|
226
234
|
// explode into linestrings to be able to track metrics
|
|
227
235
|
for (const line of geom.coordinates) {
|
|
228
|
-
const out = [];
|
|
236
|
+
const out = { points: [] };
|
|
229
237
|
convertLine(line, out, tolerance, false);
|
|
230
238
|
features.push(createFeature(id, 'LineString', out, properties));
|
|
231
239
|
}
|
|
@@ -256,7 +264,7 @@ function convertLine(ring, out, tolerance, isPolygon) {
|
|
|
256
264
|
for (let j = 0; j < ring.length; j++) {
|
|
257
265
|
const x = projectX(ring[j][0]);
|
|
258
266
|
const y = projectY(ring[j][1]);
|
|
259
|
-
out.push(x, y, 0);
|
|
267
|
+
out.points.push(x, y, 0);
|
|
260
268
|
if (j > 0) {
|
|
261
269
|
if (isPolygon) {
|
|
262
270
|
size += (x0 * y - x * y0) / 2; // area
|
|
@@ -268,18 +276,19 @@ function convertLine(ring, out, tolerance, isPolygon) {
|
|
|
268
276
|
x0 = x;
|
|
269
277
|
y0 = y;
|
|
270
278
|
}
|
|
271
|
-
const last = out.length - 3;
|
|
272
|
-
out[2] = 1;
|
|
279
|
+
const last = out.points.length - 3;
|
|
280
|
+
out.points[2] = 1;
|
|
273
281
|
if (tolerance > 0)
|
|
274
|
-
simplify(out, 0, last, tolerance);
|
|
275
|
-
out[last + 2] = 1;
|
|
282
|
+
simplify(out.points, 0, last, tolerance);
|
|
283
|
+
out.points[last + 2] = 1;
|
|
284
|
+
optimizeLineMemory(out);
|
|
276
285
|
out.size = Math.abs(size);
|
|
277
286
|
out.start = 0;
|
|
278
287
|
out.end = out.size;
|
|
279
288
|
}
|
|
280
289
|
function convertLines(rings, out, tolerance, isPolygon) {
|
|
281
290
|
for (let i = 0; i < rings.length; i++) {
|
|
282
|
-
const geom = [];
|
|
291
|
+
const geom = { points: [] };
|
|
283
292
|
convertLine(rings[i], geom, tolerance, isPolygon);
|
|
284
293
|
out.push(geom);
|
|
285
294
|
}
|
|
@@ -335,21 +344,25 @@ function geometryToGeoJSON(feature) {
|
|
|
335
344
|
coordinates: unprojectPoint(geometry[0], geometry[1])
|
|
336
345
|
};
|
|
337
346
|
case 'MultiPoint':
|
|
338
|
-
case 'LineString':
|
|
339
347
|
return {
|
|
340
348
|
type: type,
|
|
341
349
|
coordinates: unprojectPoints(geometry)
|
|
342
350
|
};
|
|
351
|
+
case 'LineString':
|
|
352
|
+
return {
|
|
353
|
+
type: type,
|
|
354
|
+
coordinates: unprojectPoints(geometry.points)
|
|
355
|
+
};
|
|
343
356
|
case 'MultiLineString':
|
|
344
357
|
case 'Polygon':
|
|
345
358
|
return {
|
|
346
359
|
type: type,
|
|
347
|
-
coordinates: geometry.map(ring => unprojectPoints(ring))
|
|
360
|
+
coordinates: geometry.map(ring => unprojectPoints(ring.points))
|
|
348
361
|
};
|
|
349
362
|
case 'MultiPolygon':
|
|
350
363
|
return {
|
|
351
364
|
type: type,
|
|
352
|
-
coordinates: geometry.map(polygon => polygon.map(ring => unprojectPoints(ring)))
|
|
365
|
+
coordinates: geometry.map(polygon => polygon.map(ring => unprojectPoints(ring.points)))
|
|
353
366
|
};
|
|
354
367
|
}
|
|
355
368
|
}
|
|
@@ -514,12 +527,12 @@ function clipLine(geom, newGeom, start, end, axis, isPolygon, trackMetrics) {
|
|
|
514
527
|
const intersect = axis === AxisType.X ? intersectX : intersectY;
|
|
515
528
|
let len = geom.start;
|
|
516
529
|
let segLen, t;
|
|
517
|
-
for (let i = 0; i < geom.length - 3; i += 3) {
|
|
518
|
-
const ax = geom[i];
|
|
519
|
-
const ay = geom[i + 1];
|
|
520
|
-
const az = geom[i + 2];
|
|
521
|
-
const bx = geom[i + 3];
|
|
522
|
-
const by = geom[i + 4];
|
|
530
|
+
for (let i = 0; i < geom.points.length - 3; i += 3) {
|
|
531
|
+
const ax = geom.points[i];
|
|
532
|
+
const ay = geom.points[i + 1];
|
|
533
|
+
const az = geom.points[i + 2];
|
|
534
|
+
const bx = geom.points[i + 3];
|
|
535
|
+
const by = geom.points[i + 4];
|
|
523
536
|
const a = axis === AxisType.X ? ax : ay;
|
|
524
537
|
const b = axis === AxisType.X ? bx : by;
|
|
525
538
|
let exited = false;
|
|
@@ -542,7 +555,7 @@ function clipLine(geom, newGeom, start, end, axis, isPolygon, trackMetrics) {
|
|
|
542
555
|
}
|
|
543
556
|
}
|
|
544
557
|
else {
|
|
545
|
-
addPoint(slice, ax, ay, az);
|
|
558
|
+
addPoint(slice.points, ax, ay, az);
|
|
546
559
|
}
|
|
547
560
|
if (b < start && a >= start) {
|
|
548
561
|
// <--|--- | or <--|-----|--- (line exits the clip region on the left)
|
|
@@ -564,29 +577,31 @@ function clipLine(geom, newGeom, start, end, axis, isPolygon, trackMetrics) {
|
|
|
564
577
|
len += segLen;
|
|
565
578
|
}
|
|
566
579
|
// add the last point
|
|
567
|
-
let last = geom.length - 3;
|
|
568
|
-
const ax = geom[last];
|
|
569
|
-
const ay = geom[last + 1];
|
|
570
|
-
const az = geom[last + 2];
|
|
580
|
+
let last = geom.points.length - 3;
|
|
581
|
+
const ax = geom.points[last];
|
|
582
|
+
const ay = geom.points[last + 1];
|
|
583
|
+
const az = geom.points[last + 2];
|
|
571
584
|
const a = axis === AxisType.X ? ax : ay;
|
|
572
585
|
if (a >= start && a <= end)
|
|
573
|
-
addPoint(slice, ax, ay, az);
|
|
586
|
+
addPoint(slice.points, ax, ay, az);
|
|
574
587
|
// close the polygon if its endpoints are not the same after clipping
|
|
575
|
-
last = slice.length - 3;
|
|
576
|
-
if (isPolygon && last >= 3 && (slice[last] !== slice[0] || slice[last + 1] !== slice[1])) {
|
|
577
|
-
addPoint(slice, slice[0], slice[1], slice[2]);
|
|
588
|
+
last = slice.points.length - 3;
|
|
589
|
+
if (isPolygon && last >= 3 && (slice.points[last] !== slice.points[0] || slice.points[last + 1] !== slice.points[1])) {
|
|
590
|
+
addPoint(slice.points, slice.points[0], slice.points[1], slice.points[2]);
|
|
578
591
|
}
|
|
579
592
|
// add the final slice
|
|
580
|
-
if (slice.length) {
|
|
593
|
+
if (slice.points.length) {
|
|
594
|
+
optimizeLineMemory(slice);
|
|
581
595
|
newGeom.push(slice);
|
|
582
596
|
}
|
|
583
597
|
}
|
|
584
598
|
function newSlice(line) {
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
599
|
+
return {
|
|
600
|
+
points: [],
|
|
601
|
+
size: line.size,
|
|
602
|
+
start: line.start,
|
|
603
|
+
end: line.end
|
|
604
|
+
};
|
|
590
605
|
}
|
|
591
606
|
function clipLines(geom, newGeom, start, end, axis, isPolygon) {
|
|
592
607
|
for (const line of geom) {
|
|
@@ -598,12 +613,12 @@ function addPoint(out, x, y, z) {
|
|
|
598
613
|
}
|
|
599
614
|
function intersectX(out, ax, ay, bx, by, x) {
|
|
600
615
|
const t = (x - ax) / (bx - ax);
|
|
601
|
-
addPoint(out, x, ay + (by - ay) * t, 1);
|
|
616
|
+
addPoint(out.points, x, ay + (by - ay) * t, 1);
|
|
602
617
|
return t;
|
|
603
618
|
}
|
|
604
619
|
function intersectY(out, ax, ay, bx, by, y) {
|
|
605
620
|
const t = (y - ay) / (by - ay);
|
|
606
|
-
addPoint(out, ax + (bx - ax) * t, y, 1);
|
|
621
|
+
addPoint(out.points, ax + (bx - ax) * t, y, 1);
|
|
607
622
|
return t;
|
|
608
623
|
}
|
|
609
624
|
|
|
@@ -626,9 +641,13 @@ function shiftFeatureCoords(features, offset) {
|
|
|
626
641
|
for (const feature of features) {
|
|
627
642
|
switch (feature.type) {
|
|
628
643
|
case 'Point':
|
|
629
|
-
case 'MultiPoint':
|
|
644
|
+
case 'MultiPoint': {
|
|
645
|
+
const newGeometry = shiftPointCoords(feature.geometry, offset);
|
|
646
|
+
newFeatures.push(createFeature(feature.id, feature.type, newGeometry, feature.tags));
|
|
647
|
+
continue;
|
|
648
|
+
}
|
|
630
649
|
case 'LineString': {
|
|
631
|
-
const newGeometry =
|
|
650
|
+
const newGeometry = shiftLineCoords(feature.geometry, offset);
|
|
632
651
|
newFeatures.push(createFeature(feature.id, feature.type, newGeometry, feature.tags));
|
|
633
652
|
continue;
|
|
634
653
|
}
|
|
@@ -636,7 +655,7 @@ function shiftFeatureCoords(features, offset) {
|
|
|
636
655
|
case 'Polygon': {
|
|
637
656
|
const newGeometry = [];
|
|
638
657
|
for (const line of feature.geometry) {
|
|
639
|
-
newGeometry.push(
|
|
658
|
+
newGeometry.push(shiftLineCoords(line, offset));
|
|
640
659
|
}
|
|
641
660
|
newFeatures.push(createFeature(feature.id, feature.type, newGeometry, feature.tags));
|
|
642
661
|
continue;
|
|
@@ -646,7 +665,7 @@ function shiftFeatureCoords(features, offset) {
|
|
|
646
665
|
for (const polygon of feature.geometry) {
|
|
647
666
|
const newPolygon = [];
|
|
648
667
|
for (const line of polygon) {
|
|
649
|
-
newPolygon.push(
|
|
668
|
+
newPolygon.push(shiftLineCoords(line, offset));
|
|
650
669
|
}
|
|
651
670
|
newGeometry.push(newPolygon);
|
|
652
671
|
}
|
|
@@ -657,17 +676,27 @@ function shiftFeatureCoords(features, offset) {
|
|
|
657
676
|
}
|
|
658
677
|
return newFeatures;
|
|
659
678
|
}
|
|
660
|
-
function
|
|
661
|
-
const
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
newPoints.start = points.start;
|
|
665
|
-
newPoints.end = points.end;
|
|
679
|
+
function shiftPointCoords(coords, offset) {
|
|
680
|
+
const newCoords = [];
|
|
681
|
+
for (let i = 0; i < coords.length; i += 3) {
|
|
682
|
+
newCoords.push(coords[i] + offset, coords[i + 1], coords[i + 2]);
|
|
666
683
|
}
|
|
667
|
-
|
|
668
|
-
|
|
684
|
+
return newCoords;
|
|
685
|
+
}
|
|
686
|
+
function shiftLineCoords(line, offset) {
|
|
687
|
+
const newLine = {
|
|
688
|
+
points: [],
|
|
689
|
+
size: line.size
|
|
690
|
+
};
|
|
691
|
+
if (line.start !== undefined) {
|
|
692
|
+
newLine.start = line.start;
|
|
693
|
+
newLine.end = line.end;
|
|
694
|
+
}
|
|
695
|
+
for (let i = 0; i < line.points.length; i += 3) {
|
|
696
|
+
newLine.points.push(line.points[i] + offset, line.points[i + 1], line.points[i + 2]);
|
|
669
697
|
}
|
|
670
|
-
|
|
698
|
+
optimizeLineMemory(newLine);
|
|
699
|
+
return newLine;
|
|
671
700
|
}
|
|
672
701
|
|
|
673
702
|
/**
|
|
@@ -679,7 +708,7 @@ function shiftCoords(points, offset) {
|
|
|
679
708
|
*/
|
|
680
709
|
function applySourceDiff(source, dataDiff, options) {
|
|
681
710
|
// convert diff to sets/maps for o(1) lookups
|
|
682
|
-
const diff = diffToHashed(dataDiff);
|
|
711
|
+
const diff = diffToHashed(dataDiff, options);
|
|
683
712
|
// collection for features that will be affected by this update and used to invalidate tiles
|
|
684
713
|
let affected = [];
|
|
685
714
|
if (diff.removeAll) {
|
|
@@ -708,26 +737,25 @@ function applySourceDiff(source, dataDiff, options) {
|
|
|
708
737
|
}
|
|
709
738
|
if (diff.update.size) {
|
|
710
739
|
// Features can be duplicated across the antimeridian (wrap) in a single tile, so must update all instances with the same id
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
oldFeatures.push(feature);
|
|
717
|
-
}
|
|
718
|
-
else {
|
|
719
|
-
keepFeatures.push(feature);
|
|
720
|
-
}
|
|
740
|
+
const oldFeaturesMap = new Map();
|
|
741
|
+
const keepFeatures = [];
|
|
742
|
+
for (const feature of source) {
|
|
743
|
+
if (diff.update.has(feature.id)) {
|
|
744
|
+
oldFeaturesMap.set(feature.id, [...(oldFeaturesMap.get(feature.id) || []), feature]);
|
|
721
745
|
}
|
|
722
|
-
|
|
746
|
+
else {
|
|
747
|
+
keepFeatures.push(feature);
|
|
748
|
+
}
|
|
749
|
+
}
|
|
750
|
+
for (const [id, update] of diff.update) {
|
|
751
|
+
const oldFeatures = oldFeaturesMap.get(id);
|
|
752
|
+
if (!oldFeatures || oldFeatures.length === 0)
|
|
723
753
|
continue;
|
|
724
754
|
const updatedFeatures = getUpdatedFeatures(oldFeatures, update, options);
|
|
725
|
-
if (!updatedFeatures.length)
|
|
726
|
-
continue;
|
|
727
755
|
affected.push(...oldFeatures, ...updatedFeatures);
|
|
728
756
|
keepFeatures.push(...updatedFeatures);
|
|
729
|
-
source = keepFeatures;
|
|
730
757
|
}
|
|
758
|
+
source = keepFeatures;
|
|
731
759
|
}
|
|
732
760
|
return { affected, source };
|
|
733
761
|
}
|
|
@@ -765,7 +793,7 @@ function getUpdatedFeatures(vtFeatures, update, options) {
|
|
|
765
793
|
}
|
|
766
794
|
return updated;
|
|
767
795
|
}
|
|
768
|
-
return
|
|
796
|
+
return vtFeatures;
|
|
769
797
|
}
|
|
770
798
|
/**
|
|
771
799
|
* helper to apply property updates from a diff update object to a properties object
|
|
@@ -790,7 +818,7 @@ function applyPropertyUpdates(tags, update) {
|
|
|
790
818
|
/**
|
|
791
819
|
* Convert a GeoJSON Source Diff to an idempotent hashed representation using Sets and Maps
|
|
792
820
|
*/
|
|
793
|
-
function diffToHashed(diff) {
|
|
821
|
+
function diffToHashed(diff, options) {
|
|
794
822
|
if (!diff)
|
|
795
823
|
return {
|
|
796
824
|
remove: new Set(),
|
|
@@ -800,7 +828,7 @@ function diffToHashed(diff) {
|
|
|
800
828
|
const hashed = {
|
|
801
829
|
removeAll: diff.removeAll,
|
|
802
830
|
remove: new Set(diff.remove || []),
|
|
803
|
-
add: new Map(diff.add?.map(feature => [feature.id, feature])),
|
|
831
|
+
add: new Map(diff.add?.map(feature => [options.promoteId ? feature.properties[options.promoteId] : feature.id, feature])),
|
|
804
832
|
update: new Map(diff.update?.map(update => [update.id, update]))
|
|
805
833
|
};
|
|
806
834
|
return hashed;
|
|
@@ -1705,14 +1733,14 @@ function addMultiPolygonTileFeature(tile, feature, tolerance) {
|
|
|
1705
1733
|
function addLine(result, geom, tile, tolerance, isPolygon, isOuter) {
|
|
1706
1734
|
const sqTolerance = tolerance * tolerance;
|
|
1707
1735
|
if (tolerance > 0 && (geom.size < (isPolygon ? sqTolerance : tolerance))) {
|
|
1708
|
-
tile.numPoints += geom.length / 3;
|
|
1736
|
+
tile.numPoints += geom.points.length / 3;
|
|
1709
1737
|
return;
|
|
1710
1738
|
}
|
|
1711
1739
|
const ring = [];
|
|
1712
|
-
for (let i = 0; i < geom.length; i += 3) {
|
|
1713
|
-
if (tolerance === 0 || geom[i + 2] > sqTolerance) {
|
|
1740
|
+
for (let i = 0; i < geom.points.length; i += 3) {
|
|
1741
|
+
if (tolerance === 0 || geom.points[i + 2] > sqTolerance) {
|
|
1714
1742
|
tile.numSimplified++;
|
|
1715
|
-
ring.push(geom[i], geom[i + 1]);
|
|
1743
|
+
ring.push(geom.points[i], geom.points[i + 1]);
|
|
1716
1744
|
}
|
|
1717
1745
|
tile.numPoints++;
|
|
1718
1746
|
}
|
|
@@ -1802,10 +1830,9 @@ function transformPoint(x, y, extent, z2, tx, ty) {
|
|
|
1802
1830
|
class TileIndex {
|
|
1803
1831
|
constructor(options) {
|
|
1804
1832
|
this.options = options;
|
|
1833
|
+
this.total = 0;
|
|
1805
1834
|
/** @internal */
|
|
1806
1835
|
this.stats = {};
|
|
1807
|
-
/** @internal */
|
|
1808
|
-
this.total = 0;
|
|
1809
1836
|
this.tiles = {};
|
|
1810
1837
|
this.tileCoords = [];
|
|
1811
1838
|
this.stats = {};
|
|
@@ -2080,30 +2107,6 @@ const defaultOptions = {
|
|
|
2080
2107
|
* Main class for creating and managing a vector tile index from GeoJSON data.
|
|
2081
2108
|
*/
|
|
2082
2109
|
class GeoJSONVT {
|
|
2083
|
-
/**
|
|
2084
|
-
* @internal
|
|
2085
|
-
* This is for the tests
|
|
2086
|
-
*/
|
|
2087
|
-
get tiles() {
|
|
2088
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
2089
|
-
return this.tileIndex?.tiles ?? {};
|
|
2090
|
-
}
|
|
2091
|
-
/**
|
|
2092
|
-
* @internal
|
|
2093
|
-
* This is for the tests
|
|
2094
|
-
*/
|
|
2095
|
-
get stats() {
|
|
2096
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
2097
|
-
return this.tileIndex.stats;
|
|
2098
|
-
}
|
|
2099
|
-
/**
|
|
2100
|
-
* @internal
|
|
2101
|
-
* This is for the tests
|
|
2102
|
-
*/
|
|
2103
|
-
get total() {
|
|
2104
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
2105
|
-
return this.tileIndex.total;
|
|
2106
|
-
}
|
|
2107
2110
|
constructor(data, options) {
|
|
2108
2111
|
options = this.options = Object.assign({}, defaultOptions, options);
|
|
2109
2112
|
const debug = options.debug;
|