@loaders.gl/mvt 4.0.0-alpha.4 → 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.d.ts +2 -0
- package/dist/bundle.d.ts.map +1 -0
- package/dist/bundle.js +2 -2
- package/dist/dist.min.js +3124 -0
- 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.d.ts +35 -0
- package/dist/helpers/binary-util-functions.d.ts.map +1 -0
- package/dist/helpers/binary-util-functions.js +111 -74
- package/dist/helpers/mapbox-util-functions.d.ts +29 -0
- package/dist/helpers/mapbox-util-functions.d.ts.map +1 -0
- package/dist/helpers/mapbox-util-functions.js +78 -45
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +9 -2
- package/dist/lib/binary-vector-tile/vector-tile-feature.d.ts +41 -0
- package/dist/lib/binary-vector-tile/vector-tile-feature.d.ts.map +1 -0
- package/dist/lib/binary-vector-tile/vector-tile-feature.js +142 -142
- package/dist/lib/binary-vector-tile/vector-tile-layer.d.ts +23 -0
- package/dist/lib/binary-vector-tile/vector-tile-layer.d.ts.map +1 -0
- package/dist/lib/binary-vector-tile/vector-tile-layer.js +85 -58
- package/dist/lib/binary-vector-tile/vector-tile.d.ts +9 -0
- package/dist/lib/binary-vector-tile/vector-tile.d.ts.map +1 -0
- 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 +27 -0
- package/dist/lib/mapbox-vector-tile/vector-tile-feature.d.ts.map +1 -0
- package/dist/lib/mapbox-vector-tile/vector-tile-feature.js +161 -193
- package/dist/lib/mapbox-vector-tile/vector-tile-layer.d.ts +20 -0
- package/dist/lib/mapbox-vector-tile/vector-tile-layer.d.ts.map +1 -0
- package/dist/lib/mapbox-vector-tile/vector-tile-layer.js +83 -58
- package/dist/lib/mapbox-vector-tile/vector-tile.d.ts +9 -0
- package/dist/lib/mapbox-vector-tile/vector-tile.d.ts.map +1 -0
- package/dist/lib/mapbox-vector-tile/vector-tile.js +25 -19
- package/dist/lib/parse-mvt.d.ts +14 -0
- package/dist/lib/parse-mvt.d.ts.map +1 -0
- package/dist/lib/parse-mvt.js +149 -98
- package/dist/lib/types.d.ts +69 -0
- package/dist/lib/types.d.ts.map +1 -0
- package/dist/lib/types.js +2 -2
- package/dist/mvt-loader.d.ts +10 -0
- package/dist/mvt-loader.d.ts.map +1 -0
- package/dist/mvt-loader.js +43 -22
- package/dist/mvt-worker.js +845 -766
- package/dist/workers/mvt-worker.d.ts +2 -0
- package/dist/workers/mvt-worker.d.ts.map +1 -0
- package/dist/workers/mvt-worker.js +5 -4
- package/package.json +10 -9
- package/src/helpers/binary-util-functions.ts +9 -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 +42 -45
- package/src/lib/binary-vector-tile/vector-tile-layer.ts +4 -4
- 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 +138 -93
- package/src/lib/types.ts +49 -72
- 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/features-to-binary.js +0 -327
- package/dist/lib/binary-vector-tile/features-to-binary.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/src/lib/binary-vector-tile/features-to-binary.ts +0 -518
- /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"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import Protobuf from 'pbf';
|
|
2
|
+
import { FlatIndexedGeometry, FlatPolygon } from '@loaders.gl/schema';
|
|
3
|
+
import VectorTileFeature from '../lib/binary-vector-tile/vector-tile-feature';
|
|
4
|
+
/**
|
|
5
|
+
* Classifies an array of rings into polygons with outer rings and holes
|
|
6
|
+
* The function also detects holes which have zero area and
|
|
7
|
+
* removes them. In doing so it modifies the input
|
|
8
|
+
* `geom.data` array to remove the unneeded data
|
|
9
|
+
*
|
|
10
|
+
* @param geometry
|
|
11
|
+
* @returns object
|
|
12
|
+
*/
|
|
13
|
+
export declare function classifyRings(geom: FlatIndexedGeometry): FlatPolygon;
|
|
14
|
+
/**
|
|
15
|
+
*
|
|
16
|
+
* @param data
|
|
17
|
+
* @param x0
|
|
18
|
+
* @param y0
|
|
19
|
+
* @param size
|
|
20
|
+
*/
|
|
21
|
+
export declare function project(data: number[], x0: number, y0: number, size: number): void;
|
|
22
|
+
/**
|
|
23
|
+
* All code below is unchanged from the original Mapbox implemenation
|
|
24
|
+
*
|
|
25
|
+
* @param tag
|
|
26
|
+
* @param feature
|
|
27
|
+
* @param pbf
|
|
28
|
+
*/
|
|
29
|
+
export declare function readFeature(tag: number, feature?: VectorTileFeature, pbf?: Protobuf): void;
|
|
30
|
+
/**
|
|
31
|
+
* @param pbf
|
|
32
|
+
* @param feature
|
|
33
|
+
*/
|
|
34
|
+
export declare function readTag(pbf: Protobuf, feature: VectorTileFeature): void;
|
|
35
|
+
//# sourceMappingURL=binary-util-functions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"binary-util-functions.d.ts","sourceRoot":"","sources":["../../src/helpers/binary-util-functions.ts"],"names":[],"mappings":"AAAA,OAAO,QAAQ,MAAM,KAAK,CAAC;AAE3B,OAAO,EAAC,mBAAmB,EAAE,WAAW,EAAC,MAAM,oBAAoB,CAAC;AACpE,OAAO,iBAAiB,MAAM,+CAA+C,CAAC;AAE9E;;;;;;;;GAQG;AAEH,wBAAgB,aAAa,CAAC,IAAI,EAAE,mBAAmB,GAAG,WAAW,CA4DpE;AAED;;;;;;GAMG;AACH,wBAAgB,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI,CAMlF;AAED;;;;;;GAMG;AACH,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,iBAAiB,EAAE,GAAG,CAAC,EAAE,QAAQ,GAAG,IAAI,CAO1F;AAED;;;GAGG;AACH,wBAAgB,OAAO,CAAC,GAAG,EAAE,QAAQ,EAAE,OAAO,EAAE,iBAAiB,GAAG,IAAI,CAQvE"}
|
|
@@ -1,81 +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
|
-
|
|
26
|
-
if (area === 0) {
|
|
27
|
-
const before = geom.data.slice(0, startIndex);
|
|
28
|
-
const after = geom.data.slice(endIndex);
|
|
29
|
-
geom.data = before.concat(after);
|
|
30
|
-
offset += endIndex - startIndex;
|
|
31
|
-
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
|
+
};
|
|
32
25
|
}
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
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)
|
|
38
65
|
areas.push(ringAreas);
|
|
66
|
+
if (polygon.length)
|
|
39
67
|
polygons.push(polygon);
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
polygon = [startIndex];
|
|
43
|
-
ringAreas = [area];
|
|
44
|
-
} else {
|
|
45
|
-
ringAreas.push(area);
|
|
46
|
-
polygon.push(startIndex);
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
if (ringAreas) areas.push(ringAreas);
|
|
51
|
-
if (polygon.length) polygons.push(polygon);
|
|
52
|
-
return {
|
|
53
|
-
areas,
|
|
54
|
-
lines: polygons,
|
|
55
|
-
data: geom.data
|
|
56
|
-
};
|
|
68
|
+
return { type, areas, indices: polygons, data: geom.data };
|
|
57
69
|
}
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
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
|
+
}
|
|
64
84
|
}
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
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
|
+
}
|
|
69
104
|
}
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
const
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
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
|
+
}
|
|
80
117
|
}
|
|
81
|
-
|
|
118
|
+
exports.readTag = readTag;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import Protobuf from 'pbf';
|
|
2
|
+
import { MVTMapboxGeometry } from '../lib/types';
|
|
3
|
+
import VectorTileFeature from '../lib/mapbox-vector-tile/vector-tile-feature';
|
|
4
|
+
/**
|
|
5
|
+
* Classifies an array of rings into polygons with outer rings and holes
|
|
6
|
+
* @param rings
|
|
7
|
+
* @returns polygons
|
|
8
|
+
*/
|
|
9
|
+
export declare function classifyRings(rings: MVTMapboxGeometry): MVTMapboxGeometry[] | number[][][];
|
|
10
|
+
/**
|
|
11
|
+
*
|
|
12
|
+
* @param ring
|
|
13
|
+
* @returns sum
|
|
14
|
+
*/
|
|
15
|
+
export declare function signedArea(ring: number[][]): number;
|
|
16
|
+
/**
|
|
17
|
+
*
|
|
18
|
+
* @param tag
|
|
19
|
+
* @param feature
|
|
20
|
+
* @param pbf
|
|
21
|
+
*/
|
|
22
|
+
export declare function readFeature(tag: number, feature?: VectorTileFeature, pbf?: Protobuf): void;
|
|
23
|
+
/**
|
|
24
|
+
*
|
|
25
|
+
* @param pbf
|
|
26
|
+
* @param feature
|
|
27
|
+
*/
|
|
28
|
+
export declare function readTag(pbf: Protobuf, feature: VectorTileFeature): void;
|
|
29
|
+
//# sourceMappingURL=mapbox-util-functions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mapbox-util-functions.d.ts","sourceRoot":"","sources":["../../src/helpers/mapbox-util-functions.ts"],"names":[],"mappings":"AAAA,OAAO,QAAQ,MAAM,KAAK,CAAC;AAC3B,OAAO,EAAC,iBAAiB,EAAC,MAAM,cAAc,CAAC;AAC/C,OAAO,iBAAiB,MAAM,+CAA+C,CAAC;AAE9E;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,iBAAiB,sCAuBrD;AAED;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,UAQ1C;AAED;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,iBAAiB,EAAE,GAAG,CAAC,EAAE,QAAQ,GAAG,IAAI,CAO1F;AAED;;;;GAIG;AACH,wBAAgB,OAAO,CAAC,GAAG,EAAE,QAAQ,EAAE,OAAO,EAAE,iBAAiB,GAAG,IAAI,CAQvE"}
|
|
@@ -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
ADDED
|
@@ -0,0 +1 @@
|
|
|
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; } });
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import Protobuf from 'pbf';
|
|
2
|
+
import { FlatFeature, FlatIndexedGeometry, GeojsonGeometryInfo } from '@loaders.gl/schema';
|
|
3
|
+
import { classifyRings } from '../../helpers/binary-util-functions';
|
|
4
|
+
export declare const TEST_EXPORTS: {
|
|
5
|
+
classifyRings: typeof classifyRings;
|
|
6
|
+
};
|
|
7
|
+
export default class VectorTileFeature {
|
|
8
|
+
properties: {
|
|
9
|
+
[x: string]: string | number | boolean | null;
|
|
10
|
+
};
|
|
11
|
+
extent: any;
|
|
12
|
+
type: number;
|
|
13
|
+
id: number | null;
|
|
14
|
+
_pbf: Protobuf;
|
|
15
|
+
_geometry: number;
|
|
16
|
+
_keys: string[];
|
|
17
|
+
_values: (string | number | boolean | null)[];
|
|
18
|
+
_geometryInfo: GeojsonGeometryInfo;
|
|
19
|
+
constructor(pbf: Protobuf, end: number, extent: any, keys: string[], values: (string | number | boolean | null)[], geometryInfo: GeojsonGeometryInfo);
|
|
20
|
+
loadGeometry(): FlatIndexedGeometry;
|
|
21
|
+
/**
|
|
22
|
+
*
|
|
23
|
+
* @param transform
|
|
24
|
+
* @returns result
|
|
25
|
+
*/
|
|
26
|
+
_toBinaryCoordinates(transform: any): {
|
|
27
|
+
type: "Feature";
|
|
28
|
+
geometry: import("@loaders.gl/schema").FlatGeometry;
|
|
29
|
+
id?: string | number | undefined;
|
|
30
|
+
properties: import("geojson").GeoJsonProperties;
|
|
31
|
+
bbox?: import("geojson").BBox | undefined;
|
|
32
|
+
};
|
|
33
|
+
toBinaryCoordinates(options: {
|
|
34
|
+
x: number;
|
|
35
|
+
y: number;
|
|
36
|
+
z: number;
|
|
37
|
+
} | ((data: number[], feature: {
|
|
38
|
+
extent: any;
|
|
39
|
+
}) => void)): FlatFeature;
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=vector-tile-feature.d.ts.map
|
|
@@ -0,0 +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,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,aAAa,EAAE,mBAAmB,CAAC;gBAIjC,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,EAC5C,YAAY,EAAE,mBAAmB;IAmBnC,YAAY,IAAI,mBAAmB;IAqDnC;;;;OAIG;IACH,oBAAoB,CAAC,SAAS,KAAA;;;;;;;IAuE9B,mBAAmB,CACjB,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,WAAW;CAWf"}
|