@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.
@@ -5,21 +5,6 @@ export declare const defaultOptions: GeoJSONVTOptions;
5
5
  * Main class for creating and managing a vector tile index from GeoJSON data.
6
6
  */
7
7
  export declare class GeoJSONVT {
8
- /**
9
- * @internal
10
- * This is for the tests
11
- */
12
- get tiles(): any;
13
- /**
14
- * @internal
15
- * This is for the tests
16
- */
17
- get stats(): any;
18
- /**
19
- * @internal
20
- * This is for the tests
21
- */
22
- get total(): any;
23
8
  private options;
24
9
  private source?;
25
10
  private tileIndex;
@@ -1 +1 @@
1
- {"version":3,"file":"geojsonvt.d.ts","sourceRoot":"","sources":["../src/geojsonvt.ts"],"names":[],"mappings":"AAGA,OAAO,EAAkB,KAAK,mBAAmB,EAAC,MAAM,cAAc,CAAC;AAGvE,OAAO,KAAK,EAAC,qBAAqB,EAAgD,gBAAgB,EAAE,aAAa,EAAE,mBAAmB,EAAC,MAAM,eAAe,CAAC;AAE7J,eAAO,MAAM,cAAc,EAAE,gBAc5B,CAAC;AAEF;;GAEG;AACH,qBAAa,SAAS;IAElB;;;OAGG;IACH,IAAW,KAAK,QAGf;IACD;;;OAGG;IACH,IAAW,KAAK,QAGf;IACA;;;MAGE;IACH,IAAW,KAAK,QAGf;IAED,OAAO,CAAC,OAAO,CAAmB;IAElC,OAAO,CAAC,MAAM,CAAC,CAA6B;IAC5C,OAAO,CAAC,SAAS,CAAqB;gBAE1B,IAAI,EAAE,OAAO,CAAC,OAAO,EAAE,OAAO,CAAC,EAAE,gBAAgB;IA8B7D,OAAO,CAAC,eAAe;IAMvB;;;;;;OAMG;IACH,OAAO,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,aAAa,GAAG,IAAI;IAUzF;;;OAGG;IACH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MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,aAAa,GAAG,IAAI;IAUzF;;;OAGG;IACH,UAAU,CAAC,IAAI,EAAE,mBAAmB,EAAE,MAAM,CAAC,EAAE,CAAC,OAAO,EAAE,OAAO,CAAC,OAAO,KAAK,OAAO;IAqBpF;;OAEG;IACH,OAAO,CAAC,YAAY;IAcpB;;OAEG;IACH,OAAO,IAAI,OAAO,CAAC,OAAO;IAK1B;;;;OAIG;IACH,oBAAoB,CAAC,OAAO,EAAE,OAAO,EAAE,cAAc,EAAE,mBAAmB;IAa1E;;;;OAIG;IACH,uBAAuB,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI;IAIzD;;;;OAIG;IACH,kBAAkB,CAAC,SAAS,EAAE,MAAM,GAAG,qBAAqB,EAAE,GAAG,IAAI;IAIrE;;;;;;OAMG;IACH,gBAAgB,CAAC,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,GAAG,IAAI;CAG9G"}
package/dist/index.d.ts CHANGED
@@ -1,10 +1,10 @@
1
1
  import type { GeoJSONVTFeatureDiff, GeoJSONVTSourceDiff } from './difference';
2
- import type { GeoJSONVTInternalFeature, GeoJSONVTInternalLineStringFeature, GeoJSONVTInternalMultiLineStringFeature, GeoJSONVTInternalMultiPointFeature, GeoJSONVTInternalMultiPolygonFeature, GeoJSONVTInternalPointFeature, GeoJSONVTInternalPolygonFeature, GeoJSONVTOptions, GeoJSONToTileOptions, PartialGeoJSONVTFeature, StartEndSizeArray, ClusterProperties, ClusterFeature, ClusterOrPointFeature, GeoJSONVTTile, GeoJSONVTFeature, GeoJSONVTFeaturePoint, GeoJSONVTFeatureNonPoint, GeoJSONVTInternalTileFeaturePoint, GeoJSONVTInternalTileFeatureNonPoint, GeoJSONVTInternalTile, GeoJSONVTInternalTileFeature, GeoJSONVTTileIndex, SuperclusterOptions } from './definitions';
2
+ import type { GeoJSONVTInternalFeature, GeoJSONVTInternalLineStringFeature, GeoJSONVTInternalMultiLineStringFeature, GeoJSONVTInternalMultiPointFeature, GeoJSONVTInternalMultiPolygonFeature, GeoJSONVTInternalPointFeature, GeoJSONVTInternalPolygonFeature, GeoJSONVTOptions, GeoJSONToTileOptions, PartialGeoJSONVTFeature, SliceArray, SliceFixedArray, ClusterProperties, ClusterFeature, ClusterOrPointFeature, GeoJSONVTTile, GeoJSONVTFeature, GeoJSONVTFeaturePoint, GeoJSONVTFeatureNonPoint, GeoJSONVTInternalTileFeaturePoint, GeoJSONVTInternalTileFeatureNonPoint, GeoJSONVTInternalTile, GeoJSONVTInternalTileFeature, GeoJSONVTTileIndex, SuperclusterOptions } from './definitions';
3
3
  import type { KDBushWithData } from './cluster-tile-index';
4
4
  import { GeoJSONVT } from './geojsonvt';
5
5
  import { ClusterTileIndex } from './cluster-tile-index';
6
6
  import { geoJSONToTile } from './geojson-to-tile';
7
7
  import { GEOJSONVT_CLIP_START, GEOJSONVT_CLIP_END } from './tile';
8
8
  export { GeoJSONVT, ClusterTileIndex as Supercluster, geoJSONToTile, GEOJSONVT_CLIP_START, GEOJSONVT_CLIP_END };
9
- export type { GeoJSONVTInternalFeature, GeoJSONVTOptions, GeoJSONToTileOptions, GeoJSONVTInternalTile, GeoJSONVTInternalTileFeature, PartialGeoJSONVTFeature, StartEndSizeArray, GeoJSONVTTile, GeoJSONVTFeature, GeoJSONVTSourceDiff, GeoJSONVTFeatureDiff, GeoJSONVTFeaturePoint, GeoJSONVTFeatureNonPoint, GeoJSONVTInternalTileFeaturePoint, GeoJSONVTInternalTileFeatureNonPoint, GeoJSONVTInternalPointFeature, GeoJSONVTInternalMultiPointFeature, GeoJSONVTInternalLineStringFeature, GeoJSONVTInternalMultiLineStringFeature, GeoJSONVTInternalPolygonFeature, GeoJSONVTInternalMultiPolygonFeature, SuperclusterOptions, ClusterProperties, ClusterFeature, ClusterOrPointFeature, KDBushWithData, GeoJSONVTTileIndex };
9
+ export type { GeoJSONVTInternalFeature, GeoJSONVTOptions, GeoJSONToTileOptions, GeoJSONVTInternalTile, GeoJSONVTInternalTileFeature, PartialGeoJSONVTFeature, SliceArray, SliceFixedArray, GeoJSONVTTile, GeoJSONVTFeature, GeoJSONVTSourceDiff, GeoJSONVTFeatureDiff, GeoJSONVTFeaturePoint, GeoJSONVTFeatureNonPoint, GeoJSONVTInternalTileFeaturePoint, GeoJSONVTInternalTileFeatureNonPoint, GeoJSONVTInternalPointFeature, GeoJSONVTInternalMultiPointFeature, GeoJSONVTInternalLineStringFeature, GeoJSONVTInternalMultiLineStringFeature, GeoJSONVTInternalPolygonFeature, GeoJSONVTInternalMultiPolygonFeature, SuperclusterOptions, ClusterProperties, ClusterFeature, ClusterOrPointFeature, KDBushWithData, GeoJSONVTTileIndex };
10
10
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAC,oBAAoB,EAAE,mBAAmB,EAAC,MAAM,cAAc,CAAC;AAC5E,OAAO,KAAK,EAAC,wBAAwB,EAAE,kCAAkC,EAAE,uCAAuC,EAAE,kCAAkC,EAAE,oCAAoC,EAAE,6BAA6B,EAAE,+BAA+B,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,uBAAuB,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,cAAc,EAAE,qBAAqB,EAAE,aAAa,EAAE,gBAAgB,EAAE,qBAAqB,EAAE,wBAAwB,EAAE,iCAAiC,EAAE,oCAAoC,EAAE,qBAAqB,EAAE,4BAA4B,EAAE,kBAAkB,EAAE,mBAAmB,EAAC,MAAM,eAAe,CAAC;AAC1pB,OAAO,KAAK,EAAC,cAAc,EAAC,MAAM,sBAAsB,CAAC;AACzD,OAAO,EAAC,SAAS,EAAC,MAAM,aAAa,CAAC;AACtC,OAAO,EAAC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,sBAAsB,CAAC;AACzD,OAAO,EAAC,SAAS,EAAC,MAAM,aAAa,CAAC;AACtC,OAAO,EAAC,gBAAgB,EAAC,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAC,aAAa,EAAC,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAC,oBAAoB,EAAE,kBAAkB,EAAC,MAAM,QAAQ,CAAC;AAEhE,OAAO,EACH,SAAS,EACT,gBAAgB,IAAI,YAAY,EAChC,aAAa,EACb,oBAAoB,EACpB,kBAAkB,EACrB,CAAA;AAED,YAAY,EACR,wBAAwB,EACxB,gBAAgB,EAChB,oBAAoB,EACpB,qBAAqB,EACrB,4BAA4B,EAC5B,uBAAuB,EACvB,UAAU,EACV,eAAe,EACf,aAAa,EACb,gBAAgB,EAChB,mBAAmB,EACnB,oBAAoB,EACpB,qBAAqB,EACrB,wBAAwB,EACxB,iCAAiC,EACjC,oCAAoC,EACpC,6BAA6B,EAC7B,kCAAkC,EAClC,kCAAkC,EAClC,uCAAuC,EACvC,+BAA+B,EAC/B,oCAAoC,EACpC,mBAAmB,EACnB,iBAAiB,EACjB,cAAc,EACd,qBAAqB,EACrB,cAAc,EACd,kBAAkB,EACrB,CAAC"}
@@ -2,6 +2,7 @@ import type { GeoJSONVTInternalFeature, GeoJSONVTOptions, ClusterOrPointFeature,
2
2
  export declare class TileIndex implements GeoJSONVTTileIndex {
3
3
  private options;
4
4
  private tileCoords;
5
+ private total;
5
6
  /** @internal */
6
7
  tiles: {
7
8
  [key: string]: GeoJSONVTInternalTile;
@@ -10,8 +11,6 @@ export declare class TileIndex implements GeoJSONVTTileIndex {
10
11
  stats: {
11
12
  [key: string]: number;
12
13
  };
13
- /** @internal */
14
- total: number;
15
14
  constructor(options: GeoJSONVTOptions);
16
15
  initialize(features: GeoJSONVTInternalFeature[]): void;
17
16
  /** {@inheritdoc} */
@@ -1 +1 @@
1
- {"version":3,"file":"tile-index.d.ts","sourceRoot":"","sources":["../src/tile-index.ts"],"names":[],"mappings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;;;;;;;;;;;;;;OAeG;IACH,OAAO,CAAC,SAAS;IA4FjB;;;;OAIG;IACH,OAAO,CAAC,eAAe;CAuE1B"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=tile-index.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tile-index.test.d.ts","sourceRoot":"","sources":["../src/tile-index.test.ts"],"names":[],"mappings":""}
@@ -1 +1 @@
1
- {"version":3,"file":"tile.d.ts","sourceRoot":"","sources":["../src/tile.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,wBAAwB,EAAyN,qBAAqB,EAAgC,gBAAgB,EAAqB,MAAM,eAAe,CAAC;AAE/W,eAAO,MAAM,oBAAoB,yBAAyB,CAAC;AAC3D,eAAO,MAAM,kBAAkB,uBAAuB,CAAC;AAEvD;;;;;;;;GAQG;AACH,wBAAgB,UAAU,CAAC,QAAQ,EAAE,wBAAwB,EAAE,EAAE,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,gBAAgB,GAAG,qBAAqB,CAwBpJ"}
1
+ {"version":3,"file":"tile.d.ts","sourceRoot":"","sources":["../src/tile.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,wBAAwB,EAAyN,qBAAqB,EAAgC,gBAAgB,EAAmB,MAAM,eAAe,CAAC;AAE7W,eAAO,MAAM,oBAAoB,yBAAyB,CAAC;AAC3D,eAAO,MAAM,kBAAkB,uBAAuB,CAAC;AAEvD;;;;;;;;GAQG;AACH,wBAAgB,UAAU,CAAC,QAAQ,EAAE,wBAAwB,EAAE,EAAE,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,gBAAgB,GAAG,qBAAqB,CAwBpJ"}
@@ -1 +1 @@
1
- {"version":3,"file":"wrap.d.ts","sourceRoot":"","sources":["../src/wrap.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,wBAAwB,EAAE,gBAAgB,EAAqB,MAAM,eAAe,CAAC;AAGnG,wBAAgB,IAAI,CAAC,QAAQ,EAAE,wBAAwB,EAAE,EAAE,OAAO,EAAE,gBAAgB,GAAG,wBAAwB,EAAE,CAehH"}
1
+ {"version":3,"file":"wrap.d.ts","sourceRoot":"","sources":["../src/wrap.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,wBAAwB,EAAE,gBAAgB,EAA+B,MAAM,eAAe,CAAC;AAG7G,wBAAgB,IAAI,CAAC,QAAQ,EAAE,wBAAwB,EAAE,EAAE,OAAO,EAAE,gBAAgB,GAAG,wBAAwB,EAAE,CAehH"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@maplibre/geojson-vt",
3
- "version": "6.0.4",
3
+ "version": "6.1.0",
4
4
  "description": "Slice GeoJSON data into vector tiles efficiently",
5
5
  "type": "module",
6
6
  "exports": {
@@ -30,16 +30,16 @@
30
30
  "@rollup/plugin-typescript": "^12.3.0",
31
31
  "@types/benchmark": "^2.1.5",
32
32
  "@types/geojson": "^7946.0.16",
33
- "@types/node": "^25.5.0",
34
- "@vitest/coverage-v8": "^4.1.0",
33
+ "@types/node": "^25.5.2",
34
+ "@vitest/coverage-v8": "^4.1.2",
35
35
  "benchmark": "^2.1.4",
36
- "eslint": "^10.0.3",
37
- "rollup": "^4.59.0",
36
+ "eslint": "^10.2.0",
37
+ "rollup": "^4.60.1",
38
38
  "tslib": "^2.8.1",
39
39
  "tsx": "^4.21.0",
40
- "typedoc": "^0.28.17",
41
- "typescript": "^5.9.3",
42
- "typescript-eslint": "^8.57.1",
40
+ "typedoc": "^0.28.18",
41
+ "typescript": "^6.0.2",
42
+ "typescript-eslint": "^8.58.0",
43
43
  "vitest": "^4.0.17"
44
44
  },
45
45
  "license": "ISC",
@@ -50,7 +50,7 @@
50
50
  "build": "rollup -c && tsc -p tsconfig.declaration.json",
51
51
  "watch": "rollup -cw",
52
52
  "start": "npm run watch",
53
- "bench": "tsx bench/benchmark.ts",
53
+ "bench": "tsx bench/benchmark.ts && tsx --expose-gc bench/memory-bench.ts",
54
54
  "docs": "typedoc && mkdir -p docs/debug && cp -r debug/* docs/debug && find docs/debug -name '*.html' -exec sed -i 's|../dist/geojson-vt-dev.js|https://unpkg.com/@maplibre/geojson-vt@latest/dist/geojson-vt.js|g' {} +",
55
55
  "prepublishOnly": "npm run test && npm run build"
56
56
  },
package/src/clip.test.ts CHANGED
@@ -1,7 +1,7 @@
1
1
 
2
2
  import {test, expect} from 'vitest';
3
3
  import {clip} from './clip';
4
- import type { StartEndSizeArray } from './definitions';
4
+ import type { SliceArray } from './definitions';
5
5
 
6
6
  const geom1 = [0,0,0,50,0,0,50,10,0,20,10,0,20,20,0,30,20,0,30,30,0,50,30,0,50,40,0,25,40,0,25,50,0,0,50,0,0,60,0,25,60,0];
7
7
  const geom2 = [0,0,0,50,0,0,50,10,0,0,10,0];
@@ -9,19 +9,19 @@ const geom2 = [0,0,0,50,0,0,50,10,0,0,10,0];
9
9
  test('clips polylines', () => {
10
10
 
11
11
  const clipped = clip([
12
- {geometry: geom1, type: 'LineString', tags: { "1": 1}, minX: 0, minY: 0, maxX: 50, maxY: 60},
13
- {geometry: geom2, type: 'LineString', tags: { "2": 2}, minX: 0, minY: 0, maxX: 50, maxY: 10}
12
+ {geometry: {points: geom1}, type: 'LineString', tags: { "1": 1}, minX: 0, minY: 0, maxX: 50, maxY: 60},
13
+ {geometry: {points: geom2}, type: 'LineString', tags: { "2": 2}, minX: 0, minY: 0, maxX: 50, maxY: 10}
14
14
  ], 1, 10, 40, 0, -Infinity, Infinity, {});
15
15
 
16
16
  const expected = [
17
17
  {id: null as string, type: 'MultiLineString', geometry: [
18
- [10,0,1,40,0,1],
19
- [40,10,1,20,10,0,20,20,0,30,20,0,30,30,0,40,30,1],
20
- [40,40,1,25,40,0,25,50,0,10,50,1],
21
- [10,60,1,25,60,0]], tags: {"1": 1}, minX: 10, minY: 0, maxX: 40, maxY: 60},
18
+ {points: [10,0,1,40,0,1]},
19
+ {points: [40,10,1,20,10,0,20,20,0,30,20,0,30,30,0,40,30,1]},
20
+ {points: [40,40,1,25,40,0,25,50,0,10,50,1]},
21
+ {points: [10,60,1,25,60,0]}], tags: {"1": 1}, minX: 10, minY: 0, maxX: 40, maxY: 60},
22
22
  {id: null as string, type: 'MultiLineString', geometry: [
23
- [10,0,1,40,0,1],
24
- [40,10,1,10,10,1]], tags: {"2": 2}, minX: 10, minY: 0, maxX: 40, maxY: 10}
23
+ {points: [10,0,1,40,0,1]},
24
+ {points: [40,10,1,10,10,1]}], tags: {"2": 2}, minX: 10, minY: 0, maxX: 40, maxY: 10}
25
25
  ];
26
26
 
27
27
  expect(JSON.stringify(clipped)).toEqual(JSON.stringify(expected));
@@ -29,27 +29,26 @@ test('clips polylines', () => {
29
29
 
30
30
  test('clips lines with line metrics on', () => {
31
31
 
32
- const geom = geom1.slice() as StartEndSizeArray;
33
- geom.size = 0;
34
- for (let i = 0; i < geom.length - 3; i += 3) {
35
- const dx = geom[i + 3] - geom[i];
36
- const dy = geom[i + 4] - geom[i + 1];
37
- geom.size += Math.sqrt(dx * dx + dy * dy);
32
+ const points = geom1.slice();
33
+ let size = 0;
34
+ for (let i = 0; i < points.length - 3; i += 3) {
35
+ const dx = points[i + 3] - points[i];
36
+ const dy = points[i + 4] - points[i + 1];
37
+ size += Math.sqrt(dx * dx + dy * dy);
38
38
  }
39
- geom.start = 0;
40
- geom.end = geom.size;
39
+ const geom: SliceArray = {points, size, start: 0, end: size};
41
40
 
42
41
  const clipped = clip([{id: 1, geometry: geom, type: 'LineString', tags: {}, minX: 0, minY: 0, maxX: 50, maxY: 60}],
43
42
  1, 10, 40, 0, -Infinity, Infinity, {lineMetrics: true});
44
43
 
45
44
  expect(
46
- clipped.map(f => [(f.geometry as StartEndSizeArray).start, (f.geometry as StartEndSizeArray).end])).toEqual(
45
+ clipped.map(f => [(f.geometry as SliceArray).start, (f.geometry as SliceArray).end])).toEqual(
47
46
  [[10, 40], [70, 130], [160, 200], [230, 245]]
48
47
  );
49
48
  });
50
49
 
51
- function closed(geometry: number[]): number[][] {
52
- return [geometry.concat(geometry.slice(0, 3))];
50
+ function closed(geometry: number[]): SliceArray[] {
51
+ return [{points: geometry.concat(geometry.slice(0, 3))}];
53
52
  }
54
53
 
55
54
  test('clips polygons', () => {
@@ -60,8 +59,8 @@ test('clips polygons', () => {
60
59
  ], 1, 10, 40, 0, -Infinity, Infinity, {});
61
60
 
62
61
  const expected = [
63
- {id: null as string, type: 'Polygon', geometry: [[10,0,1,40,0,1,40,10,1,20,10,0,20,20,0,30,20,0,30,30,0,40,30,1,40,40,1,25,40,0,25,50,0,10,50,1,10,60,1,25,60,0,10,24,1,10,0,1]], tags: {"1": 1}, minX: 10, minY: 0, maxX: 40, maxY: 60},
64
- {id: null as string, type: 'Polygon', geometry: [[10,0,1,40,0,1,40,10,1,10,10,1,10,0,1]], tags: {"2": 2}, minX: 10, minY: 0, maxX: 40, maxY: 10}
62
+ {id: null as string, type: 'Polygon', geometry: [{points: [10,0,1,40,0,1,40,10,1,20,10,0,20,20,0,30,20,0,30,30,0,40,30,1,40,40,1,25,40,0,25,50,0,10,50,1,10,60,1,25,60,0,10,24,1,10,0,1]}], tags: {"1": 1}, minX: 10, minY: 0, maxX: 40, maxY: 60},
63
+ {id: null as string, type: 'Polygon', geometry: [{points: [10,0,1,40,0,1,40,10,1,10,10,1,10,0,1]}], tags: {"2": 2}, minX: 10, minY: 0, maxX: 40, maxY: 10}
65
64
  ];
66
65
 
67
66
  expect(JSON.stringify(clipped)).toEqual(JSON.stringify(expected));
package/src/clip.ts CHANGED
@@ -1,6 +1,6 @@
1
1
 
2
- import {createFeature} from './feature';
3
- import type { GeoJSONVTInternalFeature, GeoJSONVTInternalLineStringFeature, GeoJSONVTInternalMultiLineStringFeature, GeoJSONVTInternalMultiPointFeature, GeoJSONVTInternalMultiPolygonFeature, GeoJSONVTInternalPointFeature, GeoJSONVTInternalPolygonFeature, GeoJSONVTOptions, StartEndSizeArray } from './definitions';
2
+ import {createFeature, optimizeLineMemory} from './feature';
3
+ import type { GeoJSONVTInternalFeature, GeoJSONVTInternalLineStringFeature, GeoJSONVTInternalMultiLineStringFeature, GeoJSONVTInternalMultiPointFeature, GeoJSONVTInternalMultiPolygonFeature, GeoJSONVTInternalPointFeature, GeoJSONVTInternalPolygonFeature, GeoJSONVTOptions, SliceArray, SliceFixedArray } from './definitions';
4
4
 
5
5
  export const enum AxisType {
6
6
  X = 0,
@@ -94,7 +94,7 @@ function clipPointFeature(feature: GeoJSONVTInternalPointFeature | GeoJSONVTInte
94
94
  }
95
95
 
96
96
  function clipLineStringFeature(feature: GeoJSONVTInternalLineStringFeature, clipped: GeoJSONVTInternalFeature[], start: number, end: number, axis: AxisType, options: GeoJSONVTOptions) {
97
- const geom: StartEndSizeArray[] = [];
97
+ const geom: SliceArray[] = [];
98
98
 
99
99
  clipLine(feature.geometry, geom, start, end, axis, false, options.lineMetrics);
100
100
  if (!geom.length) return;
@@ -115,7 +115,7 @@ function clipLineStringFeature(feature: GeoJSONVTInternalLineStringFeature, clip
115
115
  }
116
116
 
117
117
  function clipMultiLineStringFeature(feature: GeoJSONVTInternalMultiLineStringFeature, clipped: GeoJSONVTInternalFeature[], start: number, end: number, axis: AxisType) {
118
- const geom: StartEndSizeArray[] = [];
118
+ const geom: SliceArray[] = [];
119
119
 
120
120
  clipLines(feature.geometry, geom, start, end, axis, false);
121
121
  if (!geom.length) return;
@@ -129,7 +129,7 @@ function clipMultiLineStringFeature(feature: GeoJSONVTInternalMultiLineStringFea
129
129
  }
130
130
 
131
131
  function clipPolygonFeature(feature: GeoJSONVTInternalPolygonFeature, clipped: GeoJSONVTInternalFeature[], start: number, end: number, axis: AxisType) {
132
- const geom: StartEndSizeArray[] = [];
132
+ const geom: SliceArray[] = [];
133
133
 
134
134
  clipLines(feature.geometry, geom, start, end, axis, true);
135
135
  if (!geom.length) return;
@@ -138,10 +138,10 @@ function clipPolygonFeature(feature: GeoJSONVTInternalPolygonFeature, clipped: G
138
138
  }
139
139
 
140
140
  function clipMultiPolygonFeature(feature: GeoJSONVTInternalMultiPolygonFeature, clipped: GeoJSONVTInternalFeature[], start: number, end: number, axis: AxisType) {
141
- const geom: StartEndSizeArray[][] = [];
141
+ const geom: SliceArray[][] = [];
142
142
 
143
143
  for (const polygon of feature.geometry) {
144
- const newPolygon: StartEndSizeArray[] = [];
144
+ const newPolygon: SliceArray[] = [];
145
145
 
146
146
  clipLines(polygon, newPolygon, start, end, axis, true);
147
147
  if (!newPolygon.length) continue;
@@ -163,19 +163,19 @@ function clipPoints(geom: number[], newGeom: number[], start: number, end: numbe
163
163
  }
164
164
  }
165
165
 
166
- function clipLine(geom: StartEndSizeArray, newGeom: StartEndSizeArray[], start: number, end: number, axis: AxisType, isPolygon: boolean, trackMetrics: boolean) {
166
+ function clipLine(geom: SliceFixedArray, newGeom: SliceArray[], start: number, end: number, axis: AxisType, isPolygon: boolean, trackMetrics: boolean) {
167
167
 
168
168
  let slice = newSlice(geom);
169
169
  const intersect = axis === AxisType.X ? intersectX : intersectY;
170
170
  let len = geom.start;
171
171
  let segLen, t;
172
172
 
173
- for (let i = 0; i < geom.length - 3; i += 3) {
174
- const ax = geom[i];
175
- const ay = geom[i + 1];
176
- const az = geom[i + 2];
177
- const bx = geom[i + 3];
178
- const by = geom[i + 4];
173
+ for (let i = 0; i < geom.points.length - 3; i += 3) {
174
+ const ax = geom.points[i];
175
+ const ay = geom.points[i + 1];
176
+ const az = geom.points[i + 2];
177
+ const bx = geom.points[i + 3];
178
+ const by = geom.points[i + 4];
179
179
  const a = axis === AxisType.X ? ax : ay;
180
180
  const b = axis === AxisType.X ? bx : by;
181
181
  let exited = false;
@@ -195,7 +195,7 @@ function clipLine(geom: StartEndSizeArray, newGeom: StartEndSizeArray[], start:
195
195
  if (trackMetrics) slice.start = len + segLen * t;
196
196
  }
197
197
  } else {
198
- addPoint(slice, ax, ay, az);
198
+ addPoint(slice.points, ax, ay, az);
199
199
  }
200
200
 
201
201
  if (b < start && a >= start) {
@@ -220,34 +220,36 @@ function clipLine(geom: StartEndSizeArray, newGeom: StartEndSizeArray[], start:
220
220
  }
221
221
 
222
222
  // add the last point
223
- let last = geom.length - 3;
224
- const ax = geom[last];
225
- const ay = geom[last + 1];
226
- const az = geom[last + 2];
223
+ let last = geom.points.length - 3;
224
+ const ax = geom.points[last];
225
+ const ay = geom.points[last + 1];
226
+ const az = geom.points[last + 2];
227
227
  const a = axis === AxisType.X ? ax : ay;
228
- if (a >= start && a <= end) addPoint(slice, ax, ay, az);
228
+ if (a >= start && a <= end) addPoint(slice.points, ax, ay, az);
229
229
 
230
230
  // close the polygon if its endpoints are not the same after clipping
231
- last = slice.length - 3;
232
- if (isPolygon && last >= 3 && (slice[last] !== slice[0] || slice[last + 1] !== slice[1])) {
233
- addPoint(slice, slice[0], slice[1], slice[2]);
231
+ last = slice.points.length - 3;
232
+ if (isPolygon && last >= 3 && (slice.points[last] !== slice.points[0] || slice.points[last + 1] !== slice.points[1])) {
233
+ addPoint(slice.points, slice.points[0], slice.points[1], slice.points[2]);
234
234
  }
235
235
 
236
236
  // add the final slice
237
- if (slice.length) {
237
+ if (slice.points.length) {
238
+ optimizeLineMemory(slice);
238
239
  newGeom.push(slice);
239
240
  }
240
241
  }
241
242
 
242
- function newSlice(line: StartEndSizeArray): StartEndSizeArray {
243
- const slice: StartEndSizeArray = [];
244
- slice.size = line.size;
245
- slice.start = line.start;
246
- slice.end = line.end;
247
- return slice;
243
+ function newSlice(line: SliceFixedArray): SliceArray {
244
+ return {
245
+ points: [],
246
+ size: line.size,
247
+ start: line.start,
248
+ end: line.end
249
+ };
248
250
  }
249
251
 
250
- function clipLines(geom: StartEndSizeArray[], newGeom: StartEndSizeArray[], start: number, end: number, axis: AxisType, isPolygon: boolean) {
252
+ function clipLines(geom: SliceFixedArray[], newGeom: SliceArray[], start: number, end: number, axis: AxisType, isPolygon: boolean) {
251
253
  for (const line of geom) {
252
254
  clipLine(line, newGeom, start, end, axis, isPolygon, false);
253
255
  }
@@ -257,14 +259,14 @@ function addPoint(out: number[], x: number, y: number, z: number) {
257
259
  out.push(x, y, z);
258
260
  }
259
261
 
260
- function intersectX(out: StartEndSizeArray, ax: number, ay: number, bx: number, by: number, x: number) {
262
+ function intersectX(out: SliceArray, ax: number, ay: number, bx: number, by: number, x: number) {
261
263
  const t = (x - ax) / (bx - ax);
262
- addPoint(out, x, ay + (by - ay) * t, 1);
264
+ addPoint(out.points, x, ay + (by - ay) * t, 1);
263
265
  return t;
264
266
  }
265
267
 
266
- function intersectY(out: StartEndSizeArray, ax: number, ay: number, bx: number, by: number, y: number) {
268
+ function intersectY(out: SliceArray, ax: number, ay: number, bx: number, by: number, y: number) {
267
269
  const t = (y - ay) / (by - ay);
268
- addPoint(out, ax + (bx - ax) * t, y, 1);
270
+ addPoint(out.points, ax + (bx - ax) * t, y, 1);
269
271
  return t;
270
272
  }
package/src/convert.ts CHANGED
@@ -1,7 +1,7 @@
1
1
 
2
2
  import {simplify} from './simplify';
3
- import {createFeature} from './feature';
4
- import type {GeoJSONVTInternalFeature, GeoJSONVTOptions, StartEndSizeArray} from './definitions';
3
+ import {createFeature, optimizeLineMemory} from './feature';
4
+ import type {GeoJSONVTInternalFeature, GeoJSONVTOptions, SliceArray} from './definitions';
5
5
 
6
6
  /**
7
7
  * converts GeoJSON to internal source features (an intermediate projected JSON vector format with simplification data)
@@ -108,7 +108,7 @@ function convertMultiPointFeature(features: GeoJSONVTInternalFeature[], id: numb
108
108
  }
109
109
 
110
110
  function convertLineStringFeature(features: GeoJSONVTInternalFeature[], id: number | string | undefined, geom: GeoJSON.LineString, tolerance: number, properties: GeoJSON.GeoJsonProperties) {
111
- const out: StartEndSizeArray = [];
111
+ const out: SliceArray = {points: []};
112
112
  convertLine(geom.coordinates, out, tolerance, false);
113
113
  features.push(createFeature(id, 'LineString', out, properties));
114
114
  }
@@ -117,34 +117,34 @@ function convertMultiLineStringFeature(features: GeoJSONVTInternalFeature[], id:
117
117
  if (options.lineMetrics) {
118
118
  // explode into linestrings to be able to track metrics
119
119
  for (const line of geom.coordinates) {
120
- const out: StartEndSizeArray = [];
120
+ const out: SliceArray = {points: []};
121
121
  convertLine(line, out, tolerance, false);
122
122
  features.push(createFeature(id, 'LineString', out, properties));
123
123
  }
124
124
  } else {
125
- const out: StartEndSizeArray[] = [];
125
+ const out: SliceArray[] = [];
126
126
  convertLines(geom.coordinates, out, tolerance, false);
127
127
  features.push(createFeature(id, 'MultiLineString', out, properties));
128
128
  }
129
129
  }
130
130
 
131
131
  function convertPolygonFeature(features: GeoJSONVTInternalFeature[], id: number | string | undefined, geom: GeoJSON.Polygon, tolerance: number, properties: GeoJSON.GeoJsonProperties) {
132
- const out: StartEndSizeArray[] = [];
132
+ const out: SliceArray[] = [];
133
133
  convertLines(geom.coordinates, out, tolerance, true);
134
134
  features.push(createFeature(id, 'Polygon', out, properties));
135
135
  }
136
136
 
137
137
  function convertMultiPolygonFeature(features: GeoJSONVTInternalFeature[], id: number | string | undefined, geom: GeoJSON.MultiPolygon, tolerance: number, properties: GeoJSON.GeoJsonProperties) {
138
- const out: StartEndSizeArray[][] = [];
138
+ const out: SliceArray[][] = [];
139
139
  for (const polygon of geom.coordinates) {
140
- const polygonOut: StartEndSizeArray[] = [];
140
+ const polygonOut: SliceArray[] = [];
141
141
  convertLines(polygon, polygonOut, tolerance, true);
142
142
  out.push(polygonOut);
143
143
  }
144
144
  features.push(createFeature(id, 'MultiPolygon', out, properties));
145
145
  }
146
146
 
147
- function convertLine(ring: GeoJSON.Position[], out: StartEndSizeArray, tolerance: number, isPolygon: boolean) {
147
+ function convertLine(ring: GeoJSON.Position[], out: SliceArray, tolerance: number, isPolygon: boolean) {
148
148
  let x0, y0;
149
149
  let size = 0;
150
150
 
@@ -152,7 +152,7 @@ function convertLine(ring: GeoJSON.Position[], out: StartEndSizeArray, tolerance
152
152
  const x = projectX(ring[j][0]);
153
153
  const y = projectY(ring[j][1]);
154
154
 
155
- out.push(x, y, 0);
155
+ out.points.push(x, y, 0);
156
156
 
157
157
  if (j > 0) {
158
158
  if (isPolygon) {
@@ -165,19 +165,20 @@ function convertLine(ring: GeoJSON.Position[], out: StartEndSizeArray, tolerance
165
165
  y0 = y;
166
166
  }
167
167
 
168
- const last = out.length - 3;
169
- out[2] = 1;
170
- if (tolerance > 0) simplify(out, 0, last, tolerance);
171
- out[last + 2] = 1;
168
+ const last = out.points.length - 3;
169
+ out.points[2] = 1;
170
+ if (tolerance > 0) simplify(out.points, 0, last, tolerance);
171
+ out.points[last + 2] = 1;
172
172
 
173
+ optimizeLineMemory(out);
173
174
  out.size = Math.abs(size);
174
175
  out.start = 0;
175
176
  out.end = out.size;
176
177
  }
177
178
 
178
- function convertLines(rings: GeoJSON.Position[][], out: StartEndSizeArray[], tolerance: number, isPolygon: boolean) {
179
+ function convertLines(rings: GeoJSON.Position[][], out: SliceArray[], tolerance: number, isPolygon: boolean) {
179
180
  for (let i = 0; i < rings.length; i++) {
180
- const geom: StartEndSizeArray = [];
181
+ const geom: SliceArray = {points: []};
181
182
  convertLine(rings[i], geom, tolerance, isPolygon);
182
183
  out.push(geom);
183
184
  }
@@ -61,7 +61,7 @@ test('featureToGeoJSON: converts LineString geometry', () => {
61
61
  const feature: GeoJSONVTInternalFeature = {
62
62
  type: 'LineString',
63
63
  id: 'line1',
64
- geometry: [0.5, 0.5, 0, 0.525, 0.5, 0, 0.525, 0.525, 0],
64
+ geometry: {points: [0.5, 0.5, 0, 0.525, 0.5, 0, 0.525, 0.525, 0]},
65
65
  tags: {highway: 'primary'},
66
66
  minX: 0.5, minY: 0.5, maxX: 0.525, maxY: 0.525
67
67
  };
@@ -77,8 +77,8 @@ test('featureToGeoJSON: converts MultiLineString geometry', () => {
77
77
  type: 'MultiLineString',
78
78
  id: 'multiline1',
79
79
  geometry: [
80
- [0.5, 0.5, 0, 0.525, 0.5, 0],
81
- [0.55, 0.55, 0, 0.575, 0.55, 0]
80
+ {points: [0.5, 0.5, 0, 0.525, 0.5, 0]},
81
+ {points: [0.55, 0.55, 0, 0.575, 0.55, 0]}
82
82
  ],
83
83
  tags: {},
84
84
  minX: 0.5, minY: 0.5, maxX: 0.575, maxY: 0.55
@@ -95,8 +95,8 @@ test('featureToGeoJSON: converts Polygon geometry', () => {
95
95
  type: 'Polygon',
96
96
  id: 'polygon1',
97
97
  geometry: [
98
- [0.5, 0.5, 0, 0.6, 0.5, 0, 0.6, 0.6, 0, 0.5, 0.6, 0, 0.5, 0.5, 0],
99
- [0.52, 0.52, 0, 0.58, 0.52, 0, 0.58, 0.58, 0, 0.52, 0.58, 0, 0.52, 0.52, 0]
98
+ {points: [0.5, 0.5, 0, 0.6, 0.5, 0, 0.6, 0.6, 0, 0.5, 0.6, 0, 0.5, 0.5, 0]},
99
+ {points: [0.52, 0.52, 0, 0.58, 0.52, 0, 0.58, 0.58, 0, 0.52, 0.58, 0, 0.52, 0.52, 0]}
100
100
  ],
101
101
  tags: {landuse: 'residential'},
102
102
  minX: 0.5, minY: 0.5, maxX: 0.6, maxY: 0.6
@@ -113,8 +113,8 @@ test('featureToGeoJSON: converts MultiPolygon geometry', () => {
113
113
  type: 'MultiPolygon',
114
114
  id: 'multipolygon1',
115
115
  geometry: [
116
- [[0.5, 0.5, 0, 0.52, 0.5, 0, 0.52, 0.52, 0, 0.5, 0.52, 0, 0.5, 0.5, 0]],
117
- [[0.55, 0.55, 0, 0.57, 0.55, 0, 0.57, 0.57, 0, 0.55, 0.57, 0, 0.55, 0.55, 0]]
116
+ [{points: [0.5, 0.5, 0, 0.52, 0.5, 0, 0.52, 0.52, 0, 0.5, 0.52, 0, 0.5, 0.5, 0]}],
117
+ [{points: [0.55, 0.55, 0, 0.57, 0.55, 0, 0.57, 0.57, 0, 0.55, 0.57, 0, 0.55, 0.55, 0]}]
118
118
  ],
119
119
  tags: {},
120
120
  minX: 0.5, minY: 0.5, maxX: 0.57, maxY: 0.57
package/src/deconvert.ts CHANGED
@@ -41,28 +41,32 @@ function geometryToGeoJSON(feature: GeoJSONVTInternalFeature): GeoJSON.Geometry
41
41
  coordinates: unprojectPoint(geometry[0], geometry[1])
42
42
  };
43
43
  case 'MultiPoint':
44
- case 'LineString':
45
44
  return {
46
45
  type: type,
47
46
  coordinates: unprojectPoints(geometry)
48
47
  };
48
+ case 'LineString':
49
+ return {
50
+ type: type,
51
+ coordinates: unprojectPoints(geometry.points)
52
+ };
49
53
  case 'MultiLineString':
50
54
  case 'Polygon':
51
55
  return {
52
56
  type: type,
53
- coordinates: geometry.map(ring => unprojectPoints(ring))
57
+ coordinates: geometry.map(ring => unprojectPoints(ring.points))
54
58
  };
55
59
  case 'MultiPolygon':
56
60
  return {
57
61
  type: type,
58
62
  coordinates: geometry.map(polygon =>
59
- polygon.map(ring => unprojectPoints(ring))
63
+ polygon.map(ring => unprojectPoints(ring.points))
60
64
  )
61
65
  };
62
66
  }
63
67
  }
64
68
 
65
- export function unprojectPoints(coords: number[]): GeoJSON.Position[] {
69
+ export function unprojectPoints(coords: number[] | Float64Array): GeoJSON.Position[] {
66
70
  const result: GeoJSON.Position[] = [];
67
71
 
68
72
  for (let i = 0; i < coords.length; i += 3) {
@@ -78,7 +78,9 @@ export type GeoJSONToTileOptions = GeoJSONVTOptions & {
78
78
  clip?: boolean;
79
79
  };
80
80
 
81
- export type StartEndSizeArray = number[] & { start?: number; end?: number; size?: number };
81
+ export type SliceArray = { points: number[]; start?: number; end?: number; size?: number };
82
+
83
+ export type SliceFixedArray = { points: number[] | Float64Array; start?: number; end?: number; size?: number };
82
84
 
83
85
  export type PartialGeoJSONVTFeature = {
84
86
  id?: number | string | undefined;
@@ -101,22 +103,22 @@ export type GeoJSONVTInternalMultiPointFeature = PartialGeoJSONVTFeature & {
101
103
 
102
104
  export type GeoJSONVTInternalLineStringFeature = PartialGeoJSONVTFeature & {
103
105
  type: 'LineString';
104
- geometry: StartEndSizeArray;
106
+ geometry: SliceFixedArray;
105
107
  };
106
108
 
107
109
  export type GeoJSONVTInternalMultiLineStringFeature = PartialGeoJSONVTFeature & {
108
110
  type: 'MultiLineString';
109
- geometry: StartEndSizeArray[];
111
+ geometry: SliceFixedArray[];
110
112
  };
111
113
 
112
114
  export type GeoJSONVTInternalPolygonFeature = PartialGeoJSONVTFeature & {
113
115
  type: 'Polygon';
114
- geometry: StartEndSizeArray[];
116
+ geometry: SliceFixedArray[];
115
117
  };
116
118
 
117
119
  export type GeoJSONVTInternalMultiPolygonFeature = PartialGeoJSONVTFeature & {
118
120
  type: 'MultiPolygon';
119
- geometry: StartEndSizeArray[][];
121
+ geometry: SliceFixedArray[][];
120
122
  };
121
123
 
122
124
  export type GeoJSONVTInternalFeature =
@@ -137,8 +137,8 @@ test('applySourceDiff: updates a feature geometry', () => {
137
137
 
138
138
  expect(source.length).toBe(1);
139
139
  expect(source[0].id).toBe('point');
140
- expect(source[0].geometry[0]).toBe(0.5027777777777778);
141
- expect(source[0].geometry[1]).toBe(0.5);
140
+ expect((source[0].geometry as number[])[0]).toBe(0.5027777777777778);
141
+ expect((source[0].geometry as number[])[1]).toBe(0.5);
142
142
  });
143
143
 
144
144
  test('applySourceDiff: adds properties', () => {