@loaders.gl/mvt 4.2.0-alpha.3 → 4.2.0-alpha.5
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/dist.dev.js +274 -252
- package/dist/dist.min.js +14 -0
- package/dist/helpers/binary-util-functions.d.ts +1 -1
- package/dist/helpers/binary-util-functions.d.ts.map +1 -1
- package/dist/helpers/binary-util-functions.js +99 -61
- package/dist/helpers/mapbox-util-functions.d.ts +2 -2
- package/dist/helpers/mapbox-util-functions.d.ts.map +1 -1
- package/dist/helpers/mapbox-util-functions.js +67 -33
- package/dist/index.cjs +37 -61
- package/dist/index.cjs.map +7 -0
- package/dist/index.d.ts +8 -8
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -1
- package/dist/lib/binary-vector-tile/vector-tile-feature.d.ts +1 -1
- package/dist/lib/binary-vector-tile/vector-tile-feature.d.ts.map +1 -1
- package/dist/lib/binary-vector-tile/vector-tile-feature.js +135 -118
- package/dist/lib/binary-vector-tile/vector-tile-layer.d.ts +1 -1
- package/dist/lib/binary-vector-tile/vector-tile-layer.d.ts.map +1 -1
- package/dist/lib/binary-vector-tile/vector-tile-layer.js +77 -38
- package/dist/lib/binary-vector-tile/vector-tile.d.ts +1 -1
- package/dist/lib/binary-vector-tile/vector-tile.d.ts.map +1 -1
- package/dist/lib/binary-vector-tile/vector-tile.js +17 -12
- package/dist/lib/geojson-tiler/clip.d.ts +1 -1
- package/dist/lib/geojson-tiler/clip.d.ts.map +1 -1
- package/dist/lib/geojson-tiler/clip.js +177 -142
- package/dist/lib/geojson-tiler/convert.d.ts +1 -1
- package/dist/lib/geojson-tiler/convert.d.ts.map +1 -1
- package/dist/lib/geojson-tiler/convert.js +116 -100
- package/dist/lib/geojson-tiler/feature.d.ts +1 -1
- package/dist/lib/geojson-tiler/feature.d.ts.map +1 -1
- package/dist/lib/geojson-tiler/feature.js +38 -29
- package/dist/lib/geojson-tiler/geojson-tiler.d.ts +1 -1
- package/dist/lib/geojson-tiler/geojson-tiler.d.ts.map +1 -1
- package/dist/lib/geojson-tiler/geojson-tiler.js +197 -159
- package/dist/lib/geojson-tiler/simplify.js +60 -40
- package/dist/lib/geojson-tiler/tile.js +108 -88
- package/dist/lib/geojson-tiler/transform.d.ts +1 -1
- package/dist/lib/geojson-tiler/transform.d.ts.map +1 -1
- package/dist/lib/geojson-tiler/transform.js +35 -26
- package/dist/lib/geojson-tiler/wrap.d.ts +1 -1
- package/dist/lib/geojson-tiler/wrap.d.ts.map +1 -1
- package/dist/lib/geojson-tiler/wrap.js +71 -53
- package/dist/lib/mapbox-vector-tile/vector-tile-feature.d.ts +1 -1
- package/dist/lib/mapbox-vector-tile/vector-tile-feature.d.ts.map +1 -1
- package/dist/lib/mapbox-vector-tile/vector-tile-feature.js +156 -151
- package/dist/lib/mapbox-vector-tile/vector-tile-layer.d.ts +1 -1
- package/dist/lib/mapbox-vector-tile/vector-tile-layer.d.ts.map +1 -1
- package/dist/lib/mapbox-vector-tile/vector-tile-layer.js +75 -38
- package/dist/lib/mapbox-vector-tile/vector-tile.d.ts +1 -1
- package/dist/lib/mapbox-vector-tile/vector-tile.d.ts.map +1 -1
- package/dist/lib/mapbox-vector-tile/vector-tile.js +17 -12
- package/dist/lib/parse-mvt.d.ts +1 -1
- package/dist/lib/parse-mvt.d.ts.map +1 -1
- package/dist/lib/parse-mvt.js +142 -115
- package/dist/lib/parse-tilejson.js +234 -176
- package/dist/lib/types.js +0 -1
- package/dist/mvt-loader.d.ts +1 -1
- package/dist/mvt-loader.d.ts.map +1 -1
- package/dist/mvt-loader.js +42 -22
- package/dist/mvt-source.js +148 -139
- package/dist/mvt-worker.js +1 -1
- package/dist/tilejson-loader.d.ts +1 -1
- package/dist/tilejson-loader.d.ts.map +1 -1
- package/dist/tilejson-loader.js +32 -31
- package/dist/workers/mvt-worker.js +0 -1
- package/package.json +12 -8
- package/dist/helpers/binary-util-functions.js.map +0 -1
- package/dist/helpers/mapbox-util-functions.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/lib/binary-vector-tile/LICENSE.txt +0 -31
- package/dist/lib/binary-vector-tile/vector-tile-feature.js.map +0 -1
- package/dist/lib/binary-vector-tile/vector-tile-layer.js.map +0 -1
- package/dist/lib/binary-vector-tile/vector-tile.js.map +0 -1
- package/dist/lib/geojson-tiler/LICENSE +0 -19
- package/dist/lib/geojson-tiler/clip.js.map +0 -1
- package/dist/lib/geojson-tiler/convert.js.map +0 -1
- package/dist/lib/geojson-tiler/feature.js.map +0 -1
- package/dist/lib/geojson-tiler/geojson-tiler.js.map +0 -1
- package/dist/lib/geojson-tiler/simplify.js.map +0 -1
- package/dist/lib/geojson-tiler/tile.js.map +0 -1
- package/dist/lib/geojson-tiler/transform.js.map +0 -1
- package/dist/lib/geojson-tiler/wrap.js.map +0 -1
- package/dist/lib/mapbox-vector-tile/LICENSE.txt +0 -31
- package/dist/lib/mapbox-vector-tile/vector-tile-feature.js.map +0 -1
- package/dist/lib/mapbox-vector-tile/vector-tile-layer.js.map +0 -1
- package/dist/lib/mapbox-vector-tile/vector-tile.js.map +0 -1
- package/dist/lib/parse-mvt.js.map +0 -1
- package/dist/lib/parse-tilejson.js.map +0 -1
- package/dist/lib/types.js.map +0 -1
- package/dist/mvt-loader.js.map +0 -1
- package/dist/mvt-source.js.map +0 -1
- package/dist/tilejson-loader.js.map +0 -1
- package/dist/workers/mvt-worker.js.map +0 -1
|
@@ -1,103 +1,123 @@
|
|
|
1
|
+
// loaders.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
// Forked from https://github.com/mapbox/geojson-vt under compatible ISC license
|
|
5
|
+
/**
|
|
6
|
+
* Create a tile from features and tile index
|
|
7
|
+
*/
|
|
1
8
|
export function createTile(features, z, tx, ty, options) {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
9
|
+
const tolerance = z === options.maxZoom ? 0 : options.tolerance / ((1 << z) * options.extent);
|
|
10
|
+
const tile = {
|
|
11
|
+
features: [],
|
|
12
|
+
numPoints: 0,
|
|
13
|
+
numSimplified: 0,
|
|
14
|
+
numFeatures: features.length,
|
|
15
|
+
source: null,
|
|
16
|
+
x: tx,
|
|
17
|
+
y: ty,
|
|
18
|
+
z,
|
|
19
|
+
transformed: false,
|
|
20
|
+
minX: 2,
|
|
21
|
+
minY: 1,
|
|
22
|
+
maxX: -1,
|
|
23
|
+
maxY: 0
|
|
24
|
+
};
|
|
25
|
+
for (const feature of features) {
|
|
26
|
+
addFeature(tile, feature, tolerance, options);
|
|
27
|
+
}
|
|
28
|
+
return tile;
|
|
22
29
|
}
|
|
30
|
+
// eslint-disable-next-line complexity, max-statements
|
|
23
31
|
function addFeature(tile, feature, tolerance, options) {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
32
|
+
const geom = feature.geometry;
|
|
33
|
+
const type = feature.type;
|
|
34
|
+
const simplified = [];
|
|
35
|
+
tile.minX = Math.min(tile.minX, feature.minX);
|
|
36
|
+
tile.minY = Math.min(tile.minY, feature.minY);
|
|
37
|
+
tile.maxX = Math.max(tile.maxX, feature.maxX);
|
|
38
|
+
tile.maxY = Math.max(tile.maxY, feature.maxY);
|
|
39
|
+
if (type === 'Point' || type === 'MultiPoint') {
|
|
40
|
+
for (let i = 0; i < geom.length; i += 3) {
|
|
41
|
+
simplified.push(geom[i], geom[i + 1]);
|
|
42
|
+
tile.numPoints++;
|
|
43
|
+
tile.numSimplified++;
|
|
44
|
+
}
|
|
36
45
|
}
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
} else if (type === 'MultiLineString' || type === 'Polygon') {
|
|
40
|
-
for (let i = 0; i < geom.length; i++) {
|
|
41
|
-
addLine(simplified, geom[i], tile, tolerance, type === 'Polygon', i === 0);
|
|
46
|
+
else if (type === 'LineString') {
|
|
47
|
+
addLine(simplified, geom, tile, tolerance, false, false);
|
|
42
48
|
}
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
addLine(simplified, polygon[i], tile, tolerance, true, i === 0);
|
|
48
|
-
}
|
|
49
|
+
else if (type === 'MultiLineString' || type === 'Polygon') {
|
|
50
|
+
for (let i = 0; i < geom.length; i++) {
|
|
51
|
+
addLine(simplified, geom[i], tile, tolerance, type === 'Polygon', i === 0);
|
|
52
|
+
}
|
|
49
53
|
}
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
tags.mapbox_clip_end = geom.end / geom.size;
|
|
54
|
+
else if (type === 'MultiPolygon') {
|
|
55
|
+
for (let k = 0; k < geom.length; k++) {
|
|
56
|
+
const polygon = geom[k];
|
|
57
|
+
for (let i = 0; i < polygon.length; i++) {
|
|
58
|
+
addLine(simplified, polygon[i], tile, tolerance, true, i === 0);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
58
61
|
}
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
62
|
+
if (simplified.length) {
|
|
63
|
+
let tags = feature.tags || null;
|
|
64
|
+
if (type === 'LineString' && options.lineMetrics) {
|
|
65
|
+
tags = {};
|
|
66
|
+
for (const key in feature.tags)
|
|
67
|
+
tags[key] = feature.tags[key];
|
|
68
|
+
// eslint-disable-next-line camelcase
|
|
69
|
+
tags.mapbox_clip_start = geom.start / geom.size;
|
|
70
|
+
// eslint-disable-next-line camelcase
|
|
71
|
+
tags.mapbox_clip_end = geom.end / geom.size;
|
|
72
|
+
}
|
|
73
|
+
// @ts-expect-error TODO - create sub type?
|
|
74
|
+
const tileFeature = {
|
|
75
|
+
geometry: simplified,
|
|
76
|
+
type: type === 'Polygon' || type === 'MultiPolygon'
|
|
77
|
+
? 3
|
|
78
|
+
: type === 'LineString' || type === 'MultiLineString'
|
|
79
|
+
? 2
|
|
80
|
+
: 1,
|
|
81
|
+
tags
|
|
82
|
+
};
|
|
83
|
+
if (feature.id !== null) {
|
|
84
|
+
tileFeature.id = feature.id;
|
|
85
|
+
}
|
|
86
|
+
tile.features.push(tileFeature);
|
|
66
87
|
}
|
|
67
|
-
tile.features.push(tileFeature);
|
|
68
|
-
}
|
|
69
88
|
}
|
|
89
|
+
// eslint-disable-next-line max-params, max-statements
|
|
70
90
|
function addLine(result, geom, tile, tolerance, isPolygon, isOuter) {
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
}
|
|
76
|
-
const ring = [];
|
|
77
|
-
for (let i = 0; i < geom.length; i += 3) {
|
|
78
|
-
if (tolerance === 0 || geom[i + 2] > sqTolerance) {
|
|
79
|
-
tile.numSimplified++;
|
|
80
|
-
ring.push(geom[i], geom[i + 1]);
|
|
91
|
+
const sqTolerance = tolerance * tolerance;
|
|
92
|
+
if (tolerance > 0 && geom.size < (isPolygon ? sqTolerance : tolerance)) {
|
|
93
|
+
tile.numPoints += geom.length / 3;
|
|
94
|
+
return;
|
|
81
95
|
}
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
96
|
+
const ring = [];
|
|
97
|
+
for (let i = 0; i < geom.length; i += 3) {
|
|
98
|
+
if (tolerance === 0 || geom[i + 2] > sqTolerance) {
|
|
99
|
+
tile.numSimplified++;
|
|
100
|
+
ring.push(geom[i], geom[i + 1]);
|
|
101
|
+
}
|
|
102
|
+
tile.numPoints++;
|
|
103
|
+
}
|
|
104
|
+
if (isPolygon)
|
|
105
|
+
rewind(ring, isOuter);
|
|
106
|
+
result.push(ring);
|
|
86
107
|
}
|
|
87
108
|
function rewind(ring, clockwise) {
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
109
|
+
let area = 0;
|
|
110
|
+
for (let i = 0, j = ring.length - 2; i < ring.length; j = i, i += 2) {
|
|
111
|
+
area += (ring[i] - ring[j]) * (ring[i + 1] + ring[j + 1]);
|
|
112
|
+
}
|
|
113
|
+
if (area > 0 === clockwise) {
|
|
114
|
+
for (let i = 0, len = ring.length; i < len / 2; i += 2) {
|
|
115
|
+
const x = ring[i];
|
|
116
|
+
const y = ring[i + 1];
|
|
117
|
+
ring[i] = ring[len - 2 - i];
|
|
118
|
+
ring[i + 1] = ring[len - 1 - i];
|
|
119
|
+
ring[len - 2 - i] = x;
|
|
120
|
+
ring[len - 1 - i] = y;
|
|
121
|
+
}
|
|
100
122
|
}
|
|
101
|
-
}
|
|
102
123
|
}
|
|
103
|
-
//# sourceMappingURL=tile.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transform.d.ts","sourceRoot":"","sources":["../../../src/lib/geojson-tiler/transform.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAC,WAAW,EAAC,
|
|
1
|
+
{"version":3,"file":"transform.d.ts","sourceRoot":"","sources":["../../../src/lib/geojson-tiler/transform.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAC,WAAW,EAAC,kBAAe;AAExC;;;GAGG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,GAAG,WAAW,CAiC5E"}
|
|
@@ -1,32 +1,41 @@
|
|
|
1
|
+
// loaders.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
// Forked from https://github.com/mapbox/geojson-vt under compatible ISC license
|
|
5
|
+
/**
|
|
6
|
+
* Transforms the coordinates of each feature in the given tile from
|
|
7
|
+
* mercator-projected space into (extent x extent) tile space.
|
|
8
|
+
*/
|
|
1
9
|
export function transformTile(tile, extent) {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
10
|
+
if (tile.transformed) {
|
|
11
|
+
return tile;
|
|
12
|
+
}
|
|
13
|
+
const z2 = 1 << tile.z;
|
|
14
|
+
const tx = tile.x;
|
|
15
|
+
const ty = tile.y;
|
|
16
|
+
for (const feature of tile.features) {
|
|
17
|
+
const geom = feature.geometry;
|
|
18
|
+
const type = feature.type;
|
|
19
|
+
feature.geometry = [];
|
|
20
|
+
if (type === 1) {
|
|
21
|
+
for (let j = 0; j < geom.length; j += 2) {
|
|
22
|
+
feature.geometry.push(transformPoint(geom[j], geom[j + 1], extent, z2, tx, ty));
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
else {
|
|
26
|
+
for (let j = 0; j < geom.length; j++) {
|
|
27
|
+
const ring = [];
|
|
28
|
+
for (let k = 0; k < geom[j].length; k += 2) {
|
|
29
|
+
ring.push(transformPoint(geom[j][k], geom[j][k + 1], extent, z2, tx, ty));
|
|
30
|
+
}
|
|
31
|
+
feature.geometry.push(ring);
|
|
32
|
+
}
|
|
21
33
|
}
|
|
22
|
-
feature.geometry.push(ring);
|
|
23
|
-
}
|
|
24
34
|
}
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
return tile;
|
|
35
|
+
tile.transformed = true;
|
|
36
|
+
return tile;
|
|
28
37
|
}
|
|
38
|
+
// eslint-disable-next-line max-params
|
|
29
39
|
function transformPoint(x, y, extent, z2, tx, ty) {
|
|
30
|
-
|
|
40
|
+
return [Math.round(extent * (x * z2 - tx)), Math.round(extent * (y * z2 - ty))];
|
|
31
41
|
}
|
|
32
|
-
//# sourceMappingURL=transform.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wrap.d.ts","sourceRoot":"","sources":["../../../src/lib/geojson-tiler/wrap.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAC,kBAAkB,EAAC,
|
|
1
|
+
{"version":3,"file":"wrap.d.ts","sourceRoot":"","sources":["../../../src/lib/geojson-tiler/wrap.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAC,kBAAkB,EAAC,kBAAe;AAI/C;;GAEG;AACH,MAAM,MAAM,WAAW,GAAG;IACxB,MAAM,EAAE,MAAM,CAAC,8CAA8C,CAAC;IAC9D,MAAM,EAAE,MAAM,CAAC,0BAA0B,CAAC;IAC1C,WAAW,EAAE,OAAO,CAAC;CACtB,CAAC;AAEF;;;;;GAKG;AACH,wBAAgB,IAAI,CAAC,QAAQ,EAAE,kBAAkB,EAAE,EAAE,OAAO,EAAE,WAAW,wBAkBxE"}
|
|
@@ -1,66 +1,84 @@
|
|
|
1
|
+
// loaders.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
// Forked from https://github.com/mapbox/geojson-vt under compatible ISC license
|
|
1
5
|
import { clip } from "./clip.js";
|
|
2
6
|
import { createFeature } from "./feature.js";
|
|
7
|
+
/**
|
|
8
|
+
* Wrap across antemeridian, by clipping into two tiles, shifting the overflowing x coordinates
|
|
9
|
+
* @param features list of features to be wrapped
|
|
10
|
+
* @param options buffer and extent
|
|
11
|
+
* @returns
|
|
12
|
+
*/
|
|
3
13
|
export function wrap(features, options) {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
14
|
+
const buffer = options.buffer / options.extent;
|
|
15
|
+
let merged = features;
|
|
16
|
+
const left = clip(features, 1, -1 - buffer, buffer, 0, -1, 2, options); // left world copy
|
|
17
|
+
const right = clip(features, 1, 1 - buffer, 2 + buffer, 0, -1, 2, options); // right world copy
|
|
18
|
+
if (left || right) {
|
|
19
|
+
merged = clip(features, 1, -buffer, 1 + buffer, 0, -1, 2, options) || []; // center world copy
|
|
20
|
+
if (left) {
|
|
21
|
+
merged = shiftFeatureCoords(left, 1).concat(merged); // merge left into center
|
|
22
|
+
}
|
|
23
|
+
if (right) {
|
|
24
|
+
merged = merged.concat(shiftFeatureCoords(right, -1)); // merge right into center
|
|
25
|
+
}
|
|
15
26
|
}
|
|
16
|
-
|
|
17
|
-
return merged;
|
|
27
|
+
return merged;
|
|
18
28
|
}
|
|
29
|
+
/**
|
|
30
|
+
* Shift the x coordinates of a list of features
|
|
31
|
+
* @param features list of features to shift x coordinates for
|
|
32
|
+
* @param offset
|
|
33
|
+
* @returns
|
|
34
|
+
*/
|
|
19
35
|
function shiftFeatureCoords(features, offset) {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
newGeometry = [];
|
|
34
|
-
for (const polygon of feature.geometry) {
|
|
35
|
-
const newPolygon = [];
|
|
36
|
-
for (const line of polygon) {
|
|
37
|
-
newPolygon.push(shiftCoords(line, offset));
|
|
36
|
+
const newFeatures = [];
|
|
37
|
+
for (let i = 0; i < features.length; i++) {
|
|
38
|
+
const feature = features[i];
|
|
39
|
+
const type = feature.type;
|
|
40
|
+
let newGeometry;
|
|
41
|
+
if (type === 'Point' || type === 'MultiPoint' || type === 'LineString') {
|
|
42
|
+
newGeometry = shiftCoords(feature.geometry, offset);
|
|
43
|
+
}
|
|
44
|
+
else if (type === 'MultiLineString' || type === 'Polygon') {
|
|
45
|
+
newGeometry = [];
|
|
46
|
+
for (const line of feature.geometry) {
|
|
47
|
+
newGeometry.push(shiftCoords(line, offset));
|
|
48
|
+
}
|
|
38
49
|
}
|
|
39
|
-
|
|
40
|
-
|
|
50
|
+
else if (type === 'MultiPolygon') {
|
|
51
|
+
newGeometry = [];
|
|
52
|
+
for (const polygon of feature.geometry) {
|
|
53
|
+
const newPolygon = [];
|
|
54
|
+
for (const line of polygon) {
|
|
55
|
+
// @ts-expect-error TODO
|
|
56
|
+
newPolygon.push(shiftCoords(line, offset));
|
|
57
|
+
}
|
|
58
|
+
newGeometry.push(newPolygon);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
newFeatures.push(createFeature(feature.id, type, newGeometry, feature.tags));
|
|
41
62
|
}
|
|
42
|
-
newFeatures
|
|
43
|
-
}
|
|
44
|
-
return newFeatures;
|
|
63
|
+
return newFeatures;
|
|
45
64
|
}
|
|
46
65
|
class Points extends Array {
|
|
47
|
-
constructor() {
|
|
48
|
-
super(...arguments);
|
|
49
|
-
this.size = void 0;
|
|
50
|
-
this.start = void 0;
|
|
51
|
-
this.end = void 0;
|
|
52
|
-
}
|
|
53
66
|
}
|
|
67
|
+
/**
|
|
68
|
+
* Shift the x coordinate of every point
|
|
69
|
+
* @param points
|
|
70
|
+
* @param offset
|
|
71
|
+
* @returns
|
|
72
|
+
*/
|
|
54
73
|
function shiftCoords(points, offset) {
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
74
|
+
const newPoints = [];
|
|
75
|
+
newPoints.size = points.size;
|
|
76
|
+
if (points.start !== undefined) {
|
|
77
|
+
newPoints.start = points.start;
|
|
78
|
+
newPoints.end = points.end;
|
|
79
|
+
}
|
|
80
|
+
for (let i = 0; i < points.length; i += 3) {
|
|
81
|
+
newPoints.push(points[i] + offset, points[i + 1], points[i + 2]);
|
|
82
|
+
}
|
|
83
|
+
return newPoints;
|
|
65
84
|
}
|
|
66
|
-
//# sourceMappingURL=wrap.js.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import Protobuf from 'pbf';
|
|
2
|
-
import { MVTMapboxCoordinates, MVTMapboxGeometry } from
|
|
2
|
+
import { MVTMapboxCoordinates, MVTMapboxGeometry } from "../types.js";
|
|
3
3
|
export default class VectorTileFeature {
|
|
4
4
|
properties: {
|
|
5
5
|
[x: string]: string | number | boolean | null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vector-tile-feature.d.ts","sourceRoot":"","sources":["../../../src/lib/mapbox-vector-tile/vector-tile-feature.ts"],"names":[],"mappings":"AACA,OAAO,QAAQ,MAAM,KAAK,CAAC;AAC3B,OAAO,EAAC,oBAAoB,EAAE,iBAAiB,EAAC,
|
|
1
|
+
{"version":3,"file":"vector-tile-feature.d.ts","sourceRoot":"","sources":["../../../src/lib/mapbox-vector-tile/vector-tile-feature.ts"],"names":[],"mappings":"AACA,OAAO,QAAQ,MAAM,KAAK,CAAC;AAC3B,OAAO,EAAC,oBAAoB,EAAE,iBAAiB,EAAC,oBAAiB;AAGjE,MAAM,CAAC,OAAO,OAAO,iBAAiB;IACpC,UAAU,EAAE;QAAC,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,CAAA;KAAC,CAAC;IAC5D,MAAM,EAAE,GAAG,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,GAAG,IAAI,CAAC;IAClB,IAAI,EAAE,QAAQ,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,OAAO,EAAE,CAAC,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,CAAC,EAAE,CAAC;IAC9C,MAAM,KAAK,KAAK,aAEf;gBAGC,GAAG,EAAE,QAAQ,EACb,GAAG,EAAE,MAAM,EACX,MAAM,EAAE,GAAG,EACX,IAAI,EAAE,MAAM,EAAE,EACd,MAAM,EAAE,CAAC,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,CAAC,EAAE;IAkB9C,YAAY,IAAI,iBAAiB;IA+CjC,IAAI;IAsCJ,UAAU,CAAC,SAAS,KAAA;IAuDpB,SAAS,CACP,OAAO,EAAE;QAAC,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAA;KAAC,GAAG,CAAC,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,OAAO,EAAE;QAAC,MAAM,EAAE,GAAG,CAAA;KAAC,KAAK,IAAI,CAAC,GAC9F,oBAAoB;CAmBxB"}
|