@loaders.gl/mvt 4.0.0-alpha.5 → 4.0.0-alpha.6
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/bundle.js +2 -2
- package/dist/dist.min.js +1748 -913
- package/dist/es5/bundle.js +6 -0
- package/dist/es5/bundle.js.map +1 -0
- package/dist/es5/helpers/binary-util-functions.js +82 -0
- package/dist/es5/helpers/binary-util-functions.js.map +1 -0
- package/dist/es5/helpers/mapbox-util-functions.js +50 -0
- package/dist/es5/helpers/mapbox-util-functions.js.map +1 -0
- package/dist/es5/index.js +26 -0
- package/dist/es5/index.js.map +1 -0
- package/dist/es5/lib/binary-vector-tile/vector-tile-feature.js +168 -0
- package/dist/es5/lib/binary-vector-tile/vector-tile-feature.js.map +1 -0
- package/dist/es5/lib/binary-vector-tile/vector-tile-layer.js +62 -0
- package/dist/es5/lib/binary-vector-tile/vector-tile-layer.js.map +1 -0
- package/dist/es5/lib/binary-vector-tile/vector-tile.js +28 -0
- package/dist/es5/lib/binary-vector-tile/vector-tile.js.map +1 -0
- package/dist/es5/lib/geojson-tiler/LICENSE +19 -0
- package/dist/es5/lib/geojson-tiler/clip.js +237 -0
- package/dist/es5/lib/geojson-tiler/clip.js.map +1 -0
- package/dist/es5/lib/geojson-tiler/convert.js +161 -0
- package/dist/es5/lib/geojson-tiler/convert.js.map +1 -0
- package/dist/es5/lib/geojson-tiler/feature.js +62 -0
- package/dist/es5/lib/geojson-tiler/feature.js.map +1 -0
- package/dist/es5/lib/geojson-tiler/geojson-tiler.js +186 -0
- package/dist/es5/lib/geojson-tiler/geojson-tiler.js.map +1 -0
- package/dist/es5/lib/geojson-tiler/simplify.js +52 -0
- package/dist/es5/lib/geojson-tiler/simplify.js.map +1 -0
- package/dist/es5/lib/geojson-tiler/tile.js +121 -0
- package/dist/es5/lib/geojson-tiler/tile.js.map +1 -0
- package/dist/es5/lib/geojson-tiler/transform.js +50 -0
- package/dist/es5/lib/geojson-tiler/transform.js.map +1 -0
- package/dist/es5/lib/geojson-tiler/wrap.js +122 -0
- package/dist/es5/lib/geojson-tiler/wrap.js.map +1 -0
- package/dist/es5/lib/mapbox-vector-tile/vector-tile-feature.js +184 -0
- package/dist/es5/lib/mapbox-vector-tile/vector-tile-feature.js.map +1 -0
- package/dist/es5/lib/mapbox-vector-tile/vector-tile-layer.js +62 -0
- package/dist/es5/lib/mapbox-vector-tile/vector-tile-layer.js.map +1 -0
- package/dist/es5/lib/mapbox-vector-tile/vector-tile.js +28 -0
- package/dist/es5/lib/mapbox-vector-tile/vector-tile.js.map +1 -0
- package/dist/es5/lib/parse-mvt.js +143 -0
- package/dist/es5/lib/parse-mvt.js.map +1 -0
- package/dist/es5/lib/types.js +2 -0
- package/dist/es5/lib/types.js.map +1 -0
- package/dist/es5/mvt-loader.js +58 -0
- package/dist/es5/mvt-loader.js.map +1 -0
- package/dist/es5/workers/mvt-worker.js +6 -0
- package/dist/es5/workers/mvt-worker.js.map +1 -0
- package/dist/esm/bundle.js +4 -0
- package/dist/esm/bundle.js.map +1 -0
- package/dist/esm/helpers/binary-util-functions.js +73 -0
- package/dist/esm/helpers/binary-util-functions.js.map +1 -0
- package/dist/esm/helpers/mapbox-util-functions.js +41 -0
- package/dist/esm/helpers/mapbox-util-functions.js.map +1 -0
- package/dist/esm/index.js +3 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/lib/binary-vector-tile/LICENSE.txt +31 -0
- package/dist/esm/lib/binary-vector-tile/vector-tile-feature.js +136 -0
- package/dist/esm/lib/binary-vector-tile/vector-tile-feature.js.map +1 -0
- package/dist/esm/lib/binary-vector-tile/vector-tile-layer.js +47 -0
- package/dist/esm/lib/binary-vector-tile/vector-tile-layer.js.map +1 -0
- package/dist/esm/lib/binary-vector-tile/vector-tile.js +19 -0
- package/dist/esm/lib/binary-vector-tile/vector-tile.js.map +1 -0
- package/dist/esm/lib/geojson-tiler/LICENSE +19 -0
- package/dist/esm/lib/geojson-tiler/clip.js +173 -0
- package/dist/esm/lib/geojson-tiler/clip.js.map +1 -0
- package/dist/esm/lib/geojson-tiler/convert.js +116 -0
- package/dist/esm/lib/geojson-tiler/convert.js.map +1 -0
- package/dist/esm/lib/geojson-tiler/feature.js +35 -0
- package/dist/esm/lib/geojson-tiler/feature.js.map +1 -0
- package/dist/esm/lib/geojson-tiler/geojson-tiler.js +171 -0
- package/dist/esm/lib/geojson-tiler/geojson-tiler.js.map +1 -0
- package/dist/esm/lib/geojson-tiler/simplify.js +46 -0
- package/dist/esm/lib/geojson-tiler/simplify.js.map +1 -0
- package/dist/esm/lib/geojson-tiler/tile.js +103 -0
- package/dist/esm/lib/geojson-tiler/tile.js.map +1 -0
- package/dist/esm/lib/geojson-tiler/transform.js +32 -0
- package/dist/esm/lib/geojson-tiler/transform.js.map +1 -0
- package/dist/esm/lib/geojson-tiler/wrap.js +67 -0
- package/dist/esm/lib/geojson-tiler/wrap.js.map +1 -0
- package/dist/esm/lib/mapbox-vector-tile/LICENSE.txt +31 -0
- package/dist/esm/lib/mapbox-vector-tile/vector-tile-feature.js +163 -0
- package/dist/esm/lib/mapbox-vector-tile/vector-tile-feature.js.map +1 -0
- package/dist/esm/lib/mapbox-vector-tile/vector-tile-layer.js +47 -0
- package/dist/esm/lib/mapbox-vector-tile/vector-tile-layer.js.map +1 -0
- package/dist/esm/lib/mapbox-vector-tile/vector-tile.js +19 -0
- package/dist/esm/lib/mapbox-vector-tile/vector-tile.js.map +1 -0
- package/dist/esm/lib/parse-mvt.js +138 -0
- package/dist/esm/lib/parse-mvt.js.map +1 -0
- package/dist/esm/lib/types.js +2 -0
- package/dist/esm/lib/types.js.map +1 -0
- package/dist/esm/mvt-loader.js +29 -0
- package/dist/esm/mvt-loader.js.map +1 -0
- package/dist/esm/workers/mvt-worker.js +4 -0
- package/dist/esm/workers/mvt-worker.js.map +1 -0
- package/dist/helpers/binary-util-functions.js +111 -77
- package/dist/helpers/mapbox-util-functions.d.ts +2 -2
- package/dist/helpers/mapbox-util-functions.js +78 -45
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +9 -2
- package/dist/lib/binary-vector-tile/vector-tile-feature.d.ts.map +1 -1
- package/dist/lib/binary-vector-tile/vector-tile-feature.js +142 -143
- package/dist/lib/binary-vector-tile/vector-tile-layer.js +85 -58
- package/dist/lib/binary-vector-tile/vector-tile.js +25 -19
- package/dist/lib/geojson-tiler/clip.d.ts +16 -0
- package/dist/lib/geojson-tiler/clip.d.ts.map +1 -0
- package/dist/lib/geojson-tiler/clip.js +209 -0
- package/dist/lib/geojson-tiler/convert.d.ts +10 -0
- package/dist/lib/geojson-tiler/convert.d.ts.map +1 -0
- package/dist/lib/geojson-tiler/convert.js +134 -0
- package/dist/lib/geojson-tiler/feature.d.ts +3 -0
- package/dist/lib/geojson-tiler/feature.d.ts.map +1 -0
- package/dist/lib/geojson-tiler/feature.js +46 -0
- package/dist/lib/geojson-tiler/geojson-tiler.d.ts +44 -0
- package/dist/lib/geojson-tiler/geojson-tiler.d.ts.map +1 -0
- package/dist/lib/geojson-tiler/geojson-tiler.js +210 -0
- package/dist/lib/geojson-tiler/simplify.d.ts +10 -0
- package/dist/lib/geojson-tiler/simplify.d.ts.map +1 -0
- package/dist/lib/geojson-tiler/simplify.js +68 -0
- package/dist/lib/geojson-tiler/tile.d.ts +38 -0
- package/dist/lib/geojson-tiler/tile.d.ts.map +1 -0
- package/dist/lib/geojson-tiler/tile.js +125 -0
- package/dist/lib/geojson-tiler/transform.d.ts +7 -0
- package/dist/lib/geojson-tiler/transform.d.ts.map +1 -0
- package/dist/lib/geojson-tiler/transform.js +43 -0
- package/dist/lib/geojson-tiler/wrap.d.ts +17 -0
- package/dist/lib/geojson-tiler/wrap.d.ts.map +1 -0
- package/dist/lib/geojson-tiler/wrap.js +86 -0
- package/dist/lib/mapbox-vector-tile/vector-tile-feature.d.ts +4 -4
- package/dist/lib/mapbox-vector-tile/vector-tile-feature.js +161 -193
- package/dist/lib/mapbox-vector-tile/vector-tile-layer.js +83 -58
- package/dist/lib/mapbox-vector-tile/vector-tile.js +25 -19
- package/dist/lib/parse-mvt.d.ts +6 -9
- package/dist/lib/parse-mvt.d.ts.map +1 -1
- package/dist/lib/parse-mvt.js +148 -98
- package/dist/lib/types.d.ts +48 -7
- package/dist/lib/types.d.ts.map +1 -1
- package/dist/lib/types.js +2 -2
- package/dist/mvt-loader.d.ts.map +1 -1
- package/dist/mvt-loader.js +43 -22
- package/dist/mvt-worker.js +903 -829
- package/dist/workers/mvt-worker.js +5 -4
- package/package.json +7 -7
- package/src/helpers/mapbox-util-functions.ts +2 -2
- package/src/index.ts +7 -0
- package/src/lib/binary-vector-tile/vector-tile-feature.ts +6 -1
- package/src/lib/geojson-tiler/LICENSE +19 -0
- package/src/lib/geojson-tiler/clip.ts +248 -0
- package/src/lib/geojson-tiler/convert.ts +158 -0
- package/src/lib/geojson-tiler/feature.ts +45 -0
- package/src/lib/geojson-tiler/geojson-tiler.ts +281 -0
- package/src/lib/geojson-tiler/simplify.ts +77 -0
- package/src/lib/geojson-tiler/tile.ts +185 -0
- package/src/lib/geojson-tiler/transform.ts +55 -0
- package/src/lib/geojson-tiler/wrap.ts +108 -0
- package/src/lib/mapbox-vector-tile/vector-tile-feature.ts +4 -4
- package/src/lib/parse-mvt.ts +136 -93
- package/src/lib/types.ts +53 -7
- package/src/mvt-loader.ts +13 -9
- package/dist/bundle.js.map +0 -1
- 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/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/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/types.js.map +0 -1
- package/dist/mvt-loader.js.map +0 -1
- package/dist/workers/mvt-worker.js.map +0 -1
- /package/dist/{lib → es5/lib}/binary-vector-tile/LICENSE.txt +0 -0
- /package/dist/{lib → es5/lib}/mapbox-vector-tile/LICENSE.txt +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mvt-loader.js","names":["parseMVT","VERSION","DEFAULT_MVT_LOADER_OPTIONS","mvt","shape","coordinates","layerProperty","layers","undefined","tileIndex","MVTWorkerLoader","name","id","module","version","extensions","mimeTypes","worker","category","options","MVTLoader","parse","arrayBuffer","parseSync","binary"],"sources":["../../src/mvt-loader.ts"],"sourcesContent":["import type {Loader, LoaderWithParser} from '@loaders.gl/loader-utils';\nimport type {MVTLoaderOptions} from './lib/types';\nimport parseMVT from './lib/parse-mvt';\n\n// __VERSION__ is injected by babel-plugin-version-inline\n// @ts-ignore TS2304: Cannot find name '__VERSION__'.\nconst VERSION = typeof __VERSION__ !== 'undefined' ? __VERSION__ : 'latest';\n\nconst DEFAULT_MVT_LOADER_OPTIONS: MVTLoaderOptions = {\n mvt: {\n shape: 'geojson',\n coordinates: 'local',\n layerProperty: 'layerName',\n layers: undefined,\n tileIndex: null\n }\n};\n\n/**\n * Worker loader for the Mapbox Vector Tile format\n */\nexport const MVTWorkerLoader: Loader = {\n name: 'Mapbox Vector Tile',\n id: 'mvt',\n module: 'mvt',\n version: VERSION,\n // Note: ArcGIS uses '.pbf' extension and 'application/octet-stream'\n extensions: ['mvt', 'pbf'],\n mimeTypes: [\n 'application/vnd.mapbox-vector-tile',\n 'application/x-protobuf'\n // 'application/octet-stream'\n ],\n worker: true,\n category: 'geometry',\n options: DEFAULT_MVT_LOADER_OPTIONS\n};\n\n/**\n * Loader for the Mapbox Vector Tile format\n */\nexport const MVTLoader: LoaderWithParser = {\n ...MVTWorkerLoader,\n parse: async (arrayBuffer, options?: MVTLoaderOptions) => parseMVT(arrayBuffer, options),\n parseSync: parseMVT,\n binary: true\n};\n"],"mappings":"AAEA,OAAOA,QAAQ,MAAM,iBAAiB;AAItC,MAAMC,OAAO,GAAG,sBAAkB,KAAK,WAAW,qBAAiB,QAAQ;AAE3E,MAAMC,0BAA4C,GAAG;EACnDC,GAAG,EAAE;IACHC,KAAK,EAAE,SAAS;IAChBC,WAAW,EAAE,OAAO;IACpBC,aAAa,EAAE,WAAW;IAC1BC,MAAM,EAAEC,SAAS;IACjBC,SAAS,EAAE;EACb;AACF,CAAC;AAKD,OAAO,MAAMC,eAAuB,GAAG;EACrCC,IAAI,EAAE,oBAAoB;EAC1BC,EAAE,EAAE,KAAK;EACTC,MAAM,EAAE,KAAK;EACbC,OAAO,EAAEb,OAAO;EAEhBc,UAAU,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC;EAC1BC,SAAS,EAAE,CACT,oCAAoC,EACpC,wBAAwB,CAEzB;EACDC,MAAM,EAAE,IAAI;EACZC,QAAQ,EAAE,UAAU;EACpBC,OAAO,EAAEjB;AACX,CAAC;AAKD,OAAO,MAAMkB,SAA2B,GAAG;EACzC,GAAGV,eAAe;EAClBW,KAAK,EAAE,MAAAA,CAAOC,WAAW,EAAEH,OAA0B,KAAKnB,QAAQ,CAACsB,WAAW,EAAEH,OAAO,CAAC;EACxFI,SAAS,EAAEvB,QAAQ;EACnBwB,MAAM,EAAE;AACV,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mvt-worker.js","names":["MVTLoader","createLoaderWorker"],"sources":["../../../src/workers/mvt-worker.ts"],"sourcesContent":["import {MVTLoader} from '../mvt-loader';\nimport {createLoaderWorker} from '@loaders.gl/loader-utils';\n\ncreateLoaderWorker(MVTLoader);\n"],"mappings":"AAAA,SAAQA,SAAS,QAAO,eAAe;AACvC,SAAQC,kBAAkB,QAAO,0BAA0B;AAE3DA,kBAAkB,CAACD,SAAS,CAAC"}
|
|
@@ -1,84 +1,118 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
const shape = geom.data.slice(startIndex, endIndex);
|
|
26
|
-
const area = getPolygonSignedArea(shape);
|
|
27
|
-
|
|
28
|
-
if (area === 0) {
|
|
29
|
-
const before = geom.data.slice(0, startIndex);
|
|
30
|
-
const after = geom.data.slice(endIndex);
|
|
31
|
-
geom.data = before.concat(after);
|
|
32
|
-
offset += endIndex - startIndex;
|
|
33
|
-
continue;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.readTag = exports.readFeature = exports.project = exports.classifyRings = void 0;
|
|
4
|
+
const polygon_1 = require("@math.gl/polygon");
|
|
5
|
+
/**
|
|
6
|
+
* Classifies an array of rings into polygons with outer rings and holes
|
|
7
|
+
* The function also detects holes which have zero area and
|
|
8
|
+
* removes them. In doing so it modifies the input
|
|
9
|
+
* `geom.data` array to remove the unneeded data
|
|
10
|
+
*
|
|
11
|
+
* @param geometry
|
|
12
|
+
* @returns object
|
|
13
|
+
*/
|
|
14
|
+
// eslint-disable-next-line max-statements
|
|
15
|
+
function classifyRings(geom) {
|
|
16
|
+
const len = geom.indices.length;
|
|
17
|
+
const type = 'Polygon';
|
|
18
|
+
if (len <= 1) {
|
|
19
|
+
return {
|
|
20
|
+
type,
|
|
21
|
+
data: geom.data,
|
|
22
|
+
areas: [[(0, polygon_1.getPolygonSignedArea)(geom.data)]],
|
|
23
|
+
indices: [geom.indices]
|
|
24
|
+
};
|
|
34
25
|
}
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
26
|
+
const areas = [];
|
|
27
|
+
const polygons = [];
|
|
28
|
+
let ringAreas = [];
|
|
29
|
+
let polygon = [];
|
|
30
|
+
let ccw;
|
|
31
|
+
let offset = 0;
|
|
32
|
+
for (let endIndex, i = 0, startIndex; i < len; i++) {
|
|
33
|
+
startIndex = geom.indices[i] - offset;
|
|
34
|
+
endIndex = geom.indices[i + 1] - offset || geom.data.length;
|
|
35
|
+
const shape = geom.data.slice(startIndex, endIndex);
|
|
36
|
+
const area = (0, polygon_1.getPolygonSignedArea)(shape);
|
|
37
|
+
if (area === 0) {
|
|
38
|
+
// This polygon has no area, so remove it from the shape
|
|
39
|
+
// Remove the section from the data array
|
|
40
|
+
const before = geom.data.slice(0, startIndex);
|
|
41
|
+
const after = geom.data.slice(endIndex);
|
|
42
|
+
geom.data = before.concat(after);
|
|
43
|
+
// Need to offset any remaining indices as we have
|
|
44
|
+
// modified the data buffer
|
|
45
|
+
offset += endIndex - startIndex;
|
|
46
|
+
// Do not add this index to the output and process next shape
|
|
47
|
+
continue; // eslint-disable-line no-continue
|
|
48
|
+
}
|
|
49
|
+
if (ccw === undefined)
|
|
50
|
+
ccw = area < 0;
|
|
51
|
+
if (ccw === area < 0) {
|
|
52
|
+
if (polygon.length) {
|
|
53
|
+
areas.push(ringAreas);
|
|
54
|
+
polygons.push(polygon);
|
|
55
|
+
}
|
|
56
|
+
polygon = [startIndex];
|
|
57
|
+
ringAreas = [area];
|
|
58
|
+
}
|
|
59
|
+
else {
|
|
60
|
+
ringAreas.push(area);
|
|
61
|
+
polygon.push(startIndex);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
if (ringAreas)
|
|
40
65
|
areas.push(ringAreas);
|
|
66
|
+
if (polygon.length)
|
|
41
67
|
polygons.push(polygon);
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
polygon = [startIndex];
|
|
45
|
-
ringAreas = [area];
|
|
46
|
-
} else {
|
|
47
|
-
ringAreas.push(area);
|
|
48
|
-
polygon.push(startIndex);
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
if (ringAreas) areas.push(ringAreas);
|
|
53
|
-
if (polygon.length) polygons.push(polygon);
|
|
54
|
-
return {
|
|
55
|
-
type,
|
|
56
|
-
areas,
|
|
57
|
-
indices: polygons,
|
|
58
|
-
data: geom.data
|
|
59
|
-
};
|
|
68
|
+
return { type, areas, indices: polygons, data: geom.data };
|
|
60
69
|
}
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
70
|
+
exports.classifyRings = classifyRings;
|
|
71
|
+
/**
|
|
72
|
+
*
|
|
73
|
+
* @param data
|
|
74
|
+
* @param x0
|
|
75
|
+
* @param y0
|
|
76
|
+
* @param size
|
|
77
|
+
*/
|
|
78
|
+
function project(data, x0, y0, size) {
|
|
79
|
+
for (let j = 0, jl = data.length; j < jl; j += 2) {
|
|
80
|
+
data[j] = ((data[j] + x0) * 360) / size - 180;
|
|
81
|
+
const y2 = 180 - ((data[j + 1] + y0) * 360) / size;
|
|
82
|
+
data[j + 1] = (360 / Math.PI) * Math.atan(Math.exp((y2 * Math.PI) / 180)) - 90;
|
|
83
|
+
}
|
|
67
84
|
}
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
85
|
+
exports.project = project;
|
|
86
|
+
/**
|
|
87
|
+
* All code below is unchanged from the original Mapbox implemenation
|
|
88
|
+
*
|
|
89
|
+
* @param tag
|
|
90
|
+
* @param feature
|
|
91
|
+
* @param pbf
|
|
92
|
+
*/
|
|
93
|
+
function readFeature(tag, feature, pbf) {
|
|
94
|
+
if (feature && pbf) {
|
|
95
|
+
if (tag === 1)
|
|
96
|
+
feature.id = pbf.readVarint();
|
|
97
|
+
else if (tag === 2)
|
|
98
|
+
readTag(pbf, feature);
|
|
99
|
+
else if (tag === 3)
|
|
100
|
+
feature.type = pbf.readVarint();
|
|
101
|
+
else if (tag === 4)
|
|
102
|
+
feature._geometry = pbf.pos;
|
|
103
|
+
}
|
|
72
104
|
}
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
const
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
105
|
+
exports.readFeature = readFeature;
|
|
106
|
+
/**
|
|
107
|
+
* @param pbf
|
|
108
|
+
* @param feature
|
|
109
|
+
*/
|
|
110
|
+
function readTag(pbf, feature) {
|
|
111
|
+
const end = pbf.readVarint() + pbf.pos;
|
|
112
|
+
while (pbf.pos < end) {
|
|
113
|
+
const key = feature._keys[pbf.readVarint()];
|
|
114
|
+
const value = feature._values[pbf.readVarint()];
|
|
115
|
+
feature.properties[key] = value;
|
|
116
|
+
}
|
|
83
117
|
}
|
|
84
|
-
|
|
118
|
+
exports.readTag = readTag;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import Protobuf from 'pbf';
|
|
2
|
-
import {
|
|
2
|
+
import { MVTMapboxGeometry } from '../lib/types';
|
|
3
3
|
import VectorTileFeature from '../lib/mapbox-vector-tile/vector-tile-feature';
|
|
4
4
|
/**
|
|
5
5
|
* Classifies an array of rings into polygons with outer rings and holes
|
|
6
6
|
* @param rings
|
|
7
7
|
* @returns polygons
|
|
8
8
|
*/
|
|
9
|
-
export declare function classifyRings(rings:
|
|
9
|
+
export declare function classifyRings(rings: MVTMapboxGeometry): MVTMapboxGeometry[] | number[][][];
|
|
10
10
|
/**
|
|
11
11
|
*
|
|
12
12
|
* @param ring
|
|
@@ -1,49 +1,82 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
if (
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.readTag = exports.readFeature = exports.signedArea = exports.classifyRings = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Classifies an array of rings into polygons with outer rings and holes
|
|
6
|
+
* @param rings
|
|
7
|
+
* @returns polygons
|
|
8
|
+
*/
|
|
9
|
+
function classifyRings(rings) {
|
|
10
|
+
const len = rings.length;
|
|
11
|
+
if (len <= 1)
|
|
12
|
+
return [rings];
|
|
13
|
+
const polygons = [];
|
|
14
|
+
let polygon;
|
|
15
|
+
let ccw;
|
|
16
|
+
for (let i = 0; i < len; i++) {
|
|
17
|
+
const area = signedArea(rings[i]);
|
|
18
|
+
if (area === 0)
|
|
19
|
+
continue; // eslint-disable-line no-continue
|
|
20
|
+
if (ccw === undefined)
|
|
21
|
+
ccw = area < 0;
|
|
22
|
+
if (ccw === area < 0) {
|
|
23
|
+
if (polygon)
|
|
24
|
+
polygons.push(polygon);
|
|
25
|
+
polygon = [rings[i]];
|
|
26
|
+
}
|
|
27
|
+
else if (polygon)
|
|
28
|
+
polygon.push(rings[i]);
|
|
29
|
+
}
|
|
30
|
+
if (polygon)
|
|
31
|
+
polygons.push(polygon);
|
|
32
|
+
return polygons;
|
|
21
33
|
}
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
34
|
+
exports.classifyRings = classifyRings;
|
|
35
|
+
/**
|
|
36
|
+
*
|
|
37
|
+
* @param ring
|
|
38
|
+
* @returns sum
|
|
39
|
+
*/
|
|
40
|
+
function signedArea(ring) {
|
|
41
|
+
let sum = 0;
|
|
42
|
+
for (let i = 0, j = ring.length - 1, p1, p2; i < ring.length; j = i++) {
|
|
43
|
+
p1 = ring[i];
|
|
44
|
+
p2 = ring[j];
|
|
45
|
+
sum += (p2[0] - p1[0]) * (p1[1] + p2[1]);
|
|
46
|
+
}
|
|
47
|
+
return sum;
|
|
32
48
|
}
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
49
|
+
exports.signedArea = signedArea;
|
|
50
|
+
/**
|
|
51
|
+
*
|
|
52
|
+
* @param tag
|
|
53
|
+
* @param feature
|
|
54
|
+
* @param pbf
|
|
55
|
+
*/
|
|
56
|
+
function readFeature(tag, feature, pbf) {
|
|
57
|
+
if (feature && pbf) {
|
|
58
|
+
if (tag === 1)
|
|
59
|
+
feature.id = pbf.readVarint();
|
|
60
|
+
else if (tag === 2)
|
|
61
|
+
readTag(pbf, feature);
|
|
62
|
+
else if (tag === 3)
|
|
63
|
+
feature.type = pbf.readVarint();
|
|
64
|
+
else if (tag === 4)
|
|
65
|
+
feature._geometry = pbf.pos;
|
|
66
|
+
}
|
|
37
67
|
}
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
68
|
+
exports.readFeature = readFeature;
|
|
69
|
+
/**
|
|
70
|
+
*
|
|
71
|
+
* @param pbf
|
|
72
|
+
* @param feature
|
|
73
|
+
*/
|
|
74
|
+
function readTag(pbf, feature) {
|
|
75
|
+
const end = pbf.readVarint() + pbf.pos;
|
|
76
|
+
while (pbf.pos < end) {
|
|
77
|
+
const key = feature._keys[pbf.readVarint()];
|
|
78
|
+
const value = feature._values[pbf.readVarint()];
|
|
79
|
+
feature.properties[key] = value;
|
|
80
|
+
}
|
|
48
81
|
}
|
|
49
|
-
|
|
82
|
+
exports.readTag = readTag;
|
package/dist/index.d.ts
CHANGED
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAC,SAAS,EAAE,eAAe,EAAC,MAAM,cAAc,CAAC;AAIxD,YAAY,EAAC,mBAAmB,EAAC,MAAM,mCAAmC,CAAC;AAC3E,OAAO,EAAC,YAAY,EAAC,MAAM,mCAAmC,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
// loaders.gl, MIT license
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.GeoJSONTiler = exports.MVTWorkerLoader = exports.MVTLoader = void 0;
|
|
5
|
+
var mvt_loader_1 = require("./mvt-loader");
|
|
6
|
+
Object.defineProperty(exports, "MVTLoader", { enumerable: true, get: function () { return mvt_loader_1.MVTLoader; } });
|
|
7
|
+
Object.defineProperty(exports, "MVTWorkerLoader", { enumerable: true, get: function () { return mvt_loader_1.MVTWorkerLoader; } });
|
|
8
|
+
var geojson_tiler_1 = require("./lib/geojson-tiler/geojson-tiler");
|
|
9
|
+
Object.defineProperty(exports, "GeoJSONTiler", { enumerable: true, get: function () { return geojson_tiler_1.GeoJSONTiler; } });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vector-tile-feature.d.ts","sourceRoot":"","sources":["../../../src/lib/binary-vector-tile/vector-tile-feature.ts"],"names":[],"mappings":"AAEA,OAAO,QAAQ,MAAM,KAAK,CAAC;AAC3B,OAAO,EAAC,WAAW,EAAE,mBAAmB,EAAE,mBAAmB,EAAC,MAAM,oBAAoB,CAAC;AACzF,OAAO,EAAC,aAAa,EAAuB,MAAM,qCAAqC,CAAC;AAWxF,eAAO,MAAM,YAAY;;CAExB,CAAC;AAEF,MAAM,CAAC,OAAO,OAAO,iBAAiB;IACpC,UAAU,EAAE;QAAC,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,G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