@loaders.gl/mvt 3.1.4 → 3.1.8
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.min.js +5 -1
- package/dist/es5/lib/binary-vector-tile/vector-tile-feature.js +9 -1
- package/dist/es5/lib/binary-vector-tile/vector-tile-feature.js.map +1 -1
- package/dist/es5/mvt-loader.js +1 -1
- package/dist/esm/lib/binary-vector-tile/vector-tile-feature.js +9 -1
- package/dist/esm/lib/binary-vector-tile/vector-tile-feature.js.map +1 -1
- package/dist/esm/mvt-loader.js +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 +5 -1
- package/dist/mvt-worker.js +6 -2
- package/package.json +5 -5
- package/src/lib/binary-vector-tile/vector-tile-feature.ts +6 -1
package/dist/dist.min.js
CHANGED
|
@@ -1053,7 +1053,11 @@
|
|
|
1053
1053
|
if (typeof options === "function") {
|
|
1054
1054
|
return this._toBinaryCoordinates(options);
|
|
1055
1055
|
}
|
|
1056
|
-
|
|
1056
|
+
const { x: x2, y: y2, z } = options;
|
|
1057
|
+
const size = this.extent * Math.pow(2, z);
|
|
1058
|
+
const x0 = this.extent * x2;
|
|
1059
|
+
const y0 = this.extent * y2;
|
|
1060
|
+
return this._toBinaryCoordinates((data) => project(data, x0, y0, size));
|
|
1057
1061
|
}
|
|
1058
1062
|
};
|
|
1059
1063
|
}
|
|
@@ -181,7 +181,15 @@ var VectorTileFeature = function () {
|
|
|
181
181
|
return this._toBinaryCoordinates(options);
|
|
182
182
|
}
|
|
183
183
|
|
|
184
|
-
|
|
184
|
+
var x = options.x,
|
|
185
|
+
y = options.y,
|
|
186
|
+
z = options.z;
|
|
187
|
+
var size = this.extent * Math.pow(2, z);
|
|
188
|
+
var x0 = this.extent * x;
|
|
189
|
+
var y0 = this.extent * y;
|
|
190
|
+
return this._toBinaryCoordinates(function (data) {
|
|
191
|
+
return (0, _binaryUtilFunctions.project)(data, x0, y0, size);
|
|
192
|
+
});
|
|
185
193
|
}
|
|
186
194
|
}]);
|
|
187
195
|
return VectorTileFeature;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/lib/binary-vector-tile/vector-tile-feature.ts"],"names":["endPos","cmd","cmdLen","length","x","y","i","TEST_EXPORTS","classifyRings","VectorTileFeature","pbf","end","extent","keys","values","geometryInfo","properties","type","id","_pbf","_geometry","_keys","_values","_geometryInfo","readFields","readFeature","pos","readVarint","indices","data","readSVarint","push","start","Error","transform","geom","loadGeometry","geometry","coordLength","pointFeaturesCount","pointPositionsCount","lineFeaturesCount","linePathsCount","linePositionsCount","polygonFeaturesCount","polygonObjectsCount","polygonRingsCount","polygonPositionsCount","result","options","_toBinaryCoordinates","project"],"mappings":";;;;;;;;;;;;;;;AAIA;;;;;;;;;;;;AAGA,IAAIA,MAAJ;AACA,IAAIC,GAAJ;AACA,IAAIC,MAAJ;AACA,IAAIC,MAAJ;AACA,IAAIC,CAAJ;AACA,IAAIC,CAAJ;AACA,IAAIC,CAAJ;AAEO,IAAMC,YAAY,GAAG;AAC1BC,EAAAA,aAAa,EAAbA;AAD0B,CAArB;;;IAIcC,iB;AAYnB,6BACEC,GADF,EAEEC,GAFF,EAGEC,MAHF,EAIEC,IAJF,EAKEC,MALF,EAMEC,YANF,EAOE;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,SAAKC,UAAL,GAAkB,EAAlB;AACA,SAAKJ,MAAL,GAAcA,MAAd;AACA,SAAKK,IAAL,GAAY,CAAZ;AACA,SAAKC,EAAL,GAAU,IAAV;AAGA,SAAKC,IAAL,GAAYT,GAAZ;AACA,SAAKU,SAAL,GAAiB,CAAC,CAAlB;AACA,SAAKC,KAAL,GAAaR,IAAb;AACA,SAAKS,OAAL,GAAeR,MAAf;AACA,SAAKS,aAAL,GAAqBR,YAArB;AAEAL,IAAAA,GAAG,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CAAmBsB,mBAAnB,IAA0CR,QAAQ,CAACT,OAAT,CAAiBzB,MAA3D;;AANF,qDAQwBkC,QAAQ,CAACT,OARjC;AAAA;;AAAA;AAQE,gEAAwC;AAAA,kBAA7BA,OAA6B;AACtC,mBAAKL,aAAL,CAAmBuB,iBAAnB,IAAwClB,OAAO,CAACzB,MAAhD;AACD;AAVH;AAAA;AAAA;AAAA;AAAA;;AAWE,eAAKoB,aAAL,CAAmBwB,qBAAnB,IAA4CV,QAAQ,CAACR,IAAT,CAAc1B,MAAd,GAAuBmC,WAAnE;AAEA;;AACF;AACE,gBAAM,IAAIL,KAAJ,kCAAoC,KAAKhB,IAAzC,EAAN;AA7BJ;;AAgCA,UAAM+B,MAAmB,GAAG;AAAC/B,QAAAA,IAAI,EAAE,SAAP;AAAkBoB,QAAAA,QAAQ,EAARA,QAAlB;AAA4BrB,QAAAA,UAAU,EAAE,KAAKA;AAA7C,OAA5B;;AAEA,UAAI,KAAKE,EAAL,KAAY,IAAhB,EAAsB;AACpB8B,QAAAA,MAAM,CAAC9B,EAAP,GAAY,KAAKA,EAAjB;AACD;;AAED,aAAO8B,MAAP;AACD;;;WAED,6BACEC,OADF,EAEe;AACb,UAAI,OAAOA,OAAP,KAAmB,UAAvB,EAAmC;AACjC,eAAO,KAAKC,oBAAL,CAA0BD,OAA1B,CAAP;AACD;;AACD,aAAO,KAAKC,oBAAL,CAA0BC,4BAA1B,CAAP;AACD","sourcesContent":["// This code is forked from https://github.com/mapbox/vector-tile-js under BSD 3-clause license.\n\nimport Protobuf from 'pbf';\nimport {FlatFeature, FlatIndexedGeometry, GeojsonGeometryInfo} from '@loaders.gl/schema';\nimport {classifyRings, project, readFeature} from '../../helpers/binary-util-functions';\n\n// Reduce GC by reusing variables\nlet endPos: number;\nlet cmd: number;\nlet cmdLen: number;\nlet length: number;\nlet x: number;\nlet y: number;\nlet i: number;\n\nexport const TEST_EXPORTS = {\n classifyRings\n};\n\nexport default class VectorTileFeature {\n properties: {[x: string]: string | number | boolean | null};\n extent: any;\n type: number;\n id: number | null;\n _pbf: Protobuf;\n _geometry: number;\n _keys: string[];\n _values: (string | number | boolean | null)[];\n _geometryInfo: GeojsonGeometryInfo;\n\n // eslint-disable-next-line max-params\n constructor(\n pbf: Protobuf,\n end: number,\n extent: any,\n keys: string[],\n values: (string | number | boolean | null)[],\n geometryInfo: GeojsonGeometryInfo\n ) {\n // Public\n this.properties = {};\n this.extent = extent;\n this.type = 0;\n this.id = null;\n\n // Private\n this._pbf = pbf;\n this._geometry = -1;\n this._keys = keys;\n this._values = values;\n this._geometryInfo = geometryInfo;\n\n pbf.readFields(readFeature, this, end);\n }\n\n // eslint-disable-next-line complexity, max-statements\n loadGeometry(): FlatIndexedGeometry {\n const pbf = this._pbf;\n pbf.pos = this._geometry;\n\n endPos = pbf.readVarint() + pbf.pos;\n cmd = 1;\n length = 0;\n x = 0;\n y = 0;\n i = 0;\n\n // Note: I attempted to replace the `data` array with a\n // Float32Array, but performance was worse, both using\n // `set()` and direct index access. Also, we cannot\n // know how large the buffer should be, so it would\n // increase memory usage\n const indices: number[] = []; // Indices where geometries start\n const data: number[] = []; // Flat array of coordinate data\n\n while (pbf.pos < endPos) {\n if (length <= 0) {\n cmdLen = pbf.readVarint();\n cmd = cmdLen & 0x7;\n length = cmdLen >> 3;\n }\n\n length--;\n\n if (cmd === 1 || cmd === 2) {\n x += pbf.readSVarint();\n y += pbf.readSVarint();\n\n if (cmd === 1) {\n // New line\n indices.push(i);\n }\n data.push(x, y);\n i += 2;\n } else if (cmd === 7) {\n // Workaround for https://github.com/mapbox/mapnik-vector-tile/issues/90\n if (i > 0) {\n const start = indices[indices.length - 1]; // start index of polygon\n data.push(data[start], data[start + 1]); // closePolygon\n i += 2;\n }\n } else {\n throw new Error(`unknown command ${cmd}`);\n }\n }\n\n return {data, indices};\n }\n\n /**\n *\n * @param transform\n * @returns result\n */\n _toBinaryCoordinates(transform) {\n // Expands the protobuf data to an intermediate Flat GeoJSON\n // data format, which maps closely to the binary data buffers.\n // It is similar to GeoJSON, but rather than storing the coordinates\n // in multidimensional arrays, we have a 1D `data` with all the\n // coordinates, and then index into this using the `indices`\n // parameter, e.g.\n //\n // geometry: {\n // type: 'Point', data: [1,2], indices: [0]\n // }\n // geometry: {\n // type: 'LineString', data: [1,2,3,4,...], indices: [0]\n // }\n // geometry: {\n // type: 'Polygon', data: [1,2,3,4,...], indices: [[0, 2]]\n // }\n // Thus the indices member lets us look up the relevant range\n // from the data array.\n // The Multi* versions of the above types share the same data\n // structure, just with multiple elements in the indices array\n const geom = this.loadGeometry();\n let geometry;\n\n // Apply the supplied transformation to data\n transform(geom.data, this);\n\n const coordLength = 2;\n\n // eslint-disable-next-line default-case\n switch (this.type) {\n case 1: // Point\n this._geometryInfo.pointFeaturesCount++;\n this._geometryInfo.pointPositionsCount += geom.indices.length;\n geometry = {type: 'Point', ...geom};\n break;\n\n case 2: // LineString\n this._geometryInfo.lineFeaturesCount++;\n this._geometryInfo.linePathsCount += geom.indices.length;\n this._geometryInfo.linePositionsCount += geom.data.length / coordLength;\n geometry = {type: 'LineString', ...geom};\n break;\n\n case 3: // Polygon\n geometry = classifyRings(geom);\n\n // Unlike Point & LineString geom.indices is a 2D array, thanks\n // to the classifyRings method\n this._geometryInfo.polygonFeaturesCount++;\n this._geometryInfo.polygonObjectsCount += geometry.indices.length;\n\n for (const indices of geometry.indices) {\n this._geometryInfo.polygonRingsCount += indices.length;\n }\n this._geometryInfo.polygonPositionsCount += geometry.data.length / coordLength;\n\n break;\n default:\n throw new Error(`Invalid geometry type: ${this.type}`);\n }\n\n const result: FlatFeature = {type: 'Feature', geometry, properties: this.properties};\n\n if (this.id !== null) {\n result.id = this.id;\n }\n\n return result;\n }\n\n toBinaryCoordinates(\n options: {x: number; y: number; z: number} | ((data: number[], feature: {extent: any}) => void)\n ): FlatFeature {\n if (typeof options === 'function') {\n return this._toBinaryCoordinates(options);\n }\n return this._toBinaryCoordinates(project);\n }\n}\n"],"file":"vector-tile-feature.js"}
|
|
1
|
+
{"version":3,"sources":["../../../../src/lib/binary-vector-tile/vector-tile-feature.ts"],"names":["endPos","cmd","cmdLen","length","x","y","i","TEST_EXPORTS","classifyRings","VectorTileFeature","pbf","end","extent","keys","values","geometryInfo","properties","type","id","_pbf","_geometry","_keys","_values","_geometryInfo","readFields","readFeature","pos","readVarint","indices","data","readSVarint","push","start","Error","transform","geom","loadGeometry","geometry","coordLength","pointFeaturesCount","pointPositionsCount","lineFeaturesCount","linePathsCount","linePositionsCount","polygonFeaturesCount","polygonObjectsCount","polygonRingsCount","polygonPositionsCount","result","options","_toBinaryCoordinates","z","size","Math","pow","x0","y0"],"mappings":";;;;;;;;;;;;;;;AAIA;;;;;;;;;;;;AAGA,IAAIA,MAAJ;AACA,IAAIC,GAAJ;AACA,IAAIC,MAAJ;AACA,IAAIC,MAAJ;AACA,IAAIC,CAAJ;AACA,IAAIC,CAAJ;AACA,IAAIC,CAAJ;AAEO,IAAMC,YAAY,GAAG;AAC1BC,EAAAA,aAAa,EAAbA;AAD0B,CAArB;;;IAIcC,iB;AAYnB,6BACEC,GADF,EAEEC,GAFF,EAGEC,MAHF,EAIEC,IAJF,EAKEC,MALF,EAMEC,YANF,EAOE;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,SAAKC,UAAL,GAAkB,EAAlB;AACA,SAAKJ,MAAL,GAAcA,MAAd;AACA,SAAKK,IAAL,GAAY,CAAZ;AACA,SAAKC,EAAL,GAAU,IAAV;AAGA,SAAKC,IAAL,GAAYT,GAAZ;AACA,SAAKU,SAAL,GAAiB,CAAC,CAAlB;AACA,SAAKC,KAAL,GAAaR,IAAb;AACA,SAAKS,OAAL,GAAeR,MAAf;AACA,SAAKS,aAAL,GAAqBR,YAArB;AAEAL,IAAAA,GAAG,CAACc,UAAJ,CAAeC,gCAAf,EAA4B,IAA5B,EAAkCd,GAAlC;AACD;;;;WAGD,wBAAoC;AAClC,UAAMD,GAAG,G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B,CAAP;AACD","sourcesContent":["// This code is forked from https://github.com/mapbox/vector-tile-js under BSD 3-clause license.\n\nimport Protobuf from 'pbf';\nimport {FlatFeature, FlatIndexedGeometry, GeojsonGeometryInfo} from '@loaders.gl/schema';\nimport {classifyRings, project, readFeature} from '../../helpers/binary-util-functions';\n\n// Reduce GC by reusing variables\nlet endPos: number;\nlet cmd: number;\nlet cmdLen: number;\nlet length: number;\nlet x: number;\nlet y: number;\nlet i: number;\n\nexport const TEST_EXPORTS = {\n classifyRings\n};\n\nexport default class VectorTileFeature {\n properties: {[x: string]: string | number | boolean | null};\n extent: any;\n type: number;\n id: number | null;\n _pbf: Protobuf;\n _geometry: number;\n _keys: string[];\n _values: (string | number | boolean | null)[];\n _geometryInfo: GeojsonGeometryInfo;\n\n // eslint-disable-next-line max-params\n constructor(\n pbf: Protobuf,\n end: number,\n extent: any,\n keys: string[],\n values: (string | number | boolean | null)[],\n geometryInfo: GeojsonGeometryInfo\n ) {\n // Public\n this.properties = {};\n this.extent = extent;\n this.type = 0;\n this.id = null;\n\n // Private\n this._pbf = pbf;\n this._geometry = -1;\n this._keys = keys;\n this._values = values;\n this._geometryInfo = geometryInfo;\n\n pbf.readFields(readFeature, this, end);\n }\n\n // eslint-disable-next-line complexity, max-statements\n loadGeometry(): FlatIndexedGeometry {\n const pbf = this._pbf;\n pbf.pos = this._geometry;\n\n endPos = pbf.readVarint() + pbf.pos;\n cmd = 1;\n length = 0;\n x = 0;\n y = 0;\n i = 0;\n\n // Note: I attempted to replace the `data` array with a\n // Float32Array, but performance was worse, both using\n // `set()` and direct index access. Also, we cannot\n // know how large the buffer should be, so it would\n // increase memory usage\n const indices: number[] = []; // Indices where geometries start\n const data: number[] = []; // Flat array of coordinate data\n\n while (pbf.pos < endPos) {\n if (length <= 0) {\n cmdLen = pbf.readVarint();\n cmd = cmdLen & 0x7;\n length = cmdLen >> 3;\n }\n\n length--;\n\n if (cmd === 1 || cmd === 2) {\n x += pbf.readSVarint();\n y += pbf.readSVarint();\n\n if (cmd === 1) {\n // New line\n indices.push(i);\n }\n data.push(x, y);\n i += 2;\n } else if (cmd === 7) {\n // Workaround for https://github.com/mapbox/mapnik-vector-tile/issues/90\n if (i > 0) {\n const start = indices[indices.length - 1]; // start index of polygon\n data.push(data[start], data[start + 1]); // closePolygon\n i += 2;\n }\n } else {\n throw new Error(`unknown command ${cmd}`);\n }\n }\n\n return {data, indices};\n }\n\n /**\n *\n * @param transform\n * @returns result\n */\n _toBinaryCoordinates(transform) {\n // Expands the protobuf data to an intermediate Flat GeoJSON\n // data format, which maps closely to the binary data buffers.\n // It is similar to GeoJSON, but rather than storing the coordinates\n // in multidimensional arrays, we have a 1D `data` with all the\n // coordinates, and then index into this using the `indices`\n // parameter, e.g.\n //\n // geometry: {\n // type: 'Point', data: [1,2], indices: [0]\n // }\n // geometry: {\n // type: 'LineString', data: [1,2,3,4,...], indices: [0]\n // }\n // geometry: {\n // type: 'Polygon', data: [1,2,3,4,...], indices: [[0, 2]]\n // }\n // Thus the indices member lets us look up the relevant range\n // from the data array.\n // The Multi* versions of the above types share the same data\n // structure, just with multiple elements in the indices array\n const geom = this.loadGeometry();\n let geometry;\n\n // Apply the supplied transformation to data\n transform(geom.data, this);\n\n const coordLength = 2;\n\n // eslint-disable-next-line default-case\n switch (this.type) {\n case 1: // Point\n this._geometryInfo.pointFeaturesCount++;\n this._geometryInfo.pointPositionsCount += geom.indices.length;\n geometry = {type: 'Point', ...geom};\n break;\n\n case 2: // LineString\n this._geometryInfo.lineFeaturesCount++;\n this._geometryInfo.linePathsCount += geom.indices.length;\n this._geometryInfo.linePositionsCount += geom.data.length / coordLength;\n geometry = {type: 'LineString', ...geom};\n break;\n\n case 3: // Polygon\n geometry = classifyRings(geom);\n\n // Unlike Point & LineString geom.indices is a 2D array, thanks\n // to the classifyRings method\n this._geometryInfo.polygonFeaturesCount++;\n this._geometryInfo.polygonObjectsCount += geometry.indices.length;\n\n for (const indices of geometry.indices) {\n this._geometryInfo.polygonRingsCount += indices.length;\n }\n this._geometryInfo.polygonPositionsCount += geometry.data.length / coordLength;\n\n break;\n default:\n throw new Error(`Invalid geometry type: ${this.type}`);\n }\n\n const result: FlatFeature = {type: 'Feature', geometry, properties: this.properties};\n\n if (this.id !== null) {\n result.id = this.id;\n }\n\n return result;\n }\n\n toBinaryCoordinates(\n options: {x: number; y: number; z: number} | ((data: number[], feature: {extent: any}) => void)\n ): FlatFeature {\n if (typeof options === 'function') {\n return this._toBinaryCoordinates(options);\n }\n const {x, y, z} = options;\n const size = this.extent * Math.pow(2, z);\n const x0 = this.extent * x;\n const y0 = this.extent * y;\n\n return this._toBinaryCoordinates((data: number[]) => project(data, x0, y0, size));\n }\n}\n"],"file":"vector-tile-feature.js"}
|
package/dist/es5/mvt-loader.js
CHANGED
|
@@ -19,7 +19,7 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (O
|
|
|
19
19
|
|
|
20
20
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
21
21
|
|
|
22
|
-
var VERSION = typeof "3.1.
|
|
22
|
+
var VERSION = typeof "3.1.8" !== 'undefined' ? "3.1.8" : 'latest';
|
|
23
23
|
var MVTWorkerLoader = {
|
|
24
24
|
name: 'Mapbox Vector Tile',
|
|
25
25
|
id: 'mvt',
|
|
@@ -150,7 +150,15 @@ export default class VectorTileFeature {
|
|
|
150
150
|
return this._toBinaryCoordinates(options);
|
|
151
151
|
}
|
|
152
152
|
|
|
153
|
-
|
|
153
|
+
const {
|
|
154
|
+
x,
|
|
155
|
+
y,
|
|
156
|
+
z
|
|
157
|
+
} = options;
|
|
158
|
+
const size = this.extent * Math.pow(2, z);
|
|
159
|
+
const x0 = this.extent * x;
|
|
160
|
+
const y0 = this.extent * y;
|
|
161
|
+
return this._toBinaryCoordinates(data => project(data, x0, y0, size));
|
|
154
162
|
}
|
|
155
163
|
|
|
156
164
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/lib/binary-vector-tile/vector-tile-feature.ts"],"names":["classifyRings","project","readFeature","endPos","cmd","cmdLen","length","x","y","i","TEST_EXPORTS","VectorTileFeature","constructor","pbf","end","extent","keys","values","geometryInfo","properties","type","id","_pbf","_geometry","_keys","_values","_geometryInfo","readFields","loadGeometry","pos","readVarint","indices","data","readSVarint","push","start","Error","_toBinaryCoordinates","transform","geom","geometry","coordLength","pointFeaturesCount","pointPositionsCount","lineFeaturesCount","linePathsCount","linePositionsCount","polygonFeaturesCount","polygonObjectsCount","polygonRingsCount","polygonPositionsCount","result","toBinaryCoordinates","options"],"mappings":";AAIA,SAAQA,aAAR,EAAuBC,OAAvB,EAAgCC,WAAhC,QAAkD,qCAAlD;AAGA,IAAIC,MAAJ;AACA,IAAIC,GAAJ;AACA,IAAIC,MAAJ;AACA,IAAIC,MAAJ;AACA,IAAIC,CAAJ;AACA,IAAIC,CAAJ;AACA,IAAIC,CAAJ;AAEA,OAAO,MAAMC,YAAY,GAAG;AAC1BV,EAAAA;AAD0B,CAArB;AAIP,eAAe,MAAMW,iBAAN,CAAwB;AAYrCC,EAAAA,WAAW,CACTC,GADS,EAETC,GAFS,EAGTC,MAHS,EAITC,IAJS,EAKTC,MALS,EAMTC,YANS,EAOT;AAAA;;AAAA;;AAAA;;AAAA;;AAAA;;AAAA;;AAAA;;AAAA;;AAAA;;AAEA,SAAKC,UAAL,GAAkB,EAAlB;AACA,SAAKJ,MAAL,GAAcA,MAAd;AACA,SAAKK,IAAL,GAAY,CAAZ;AACA,SAAKC,EAAL,GAAU,IAAV;AAGA,SAAKC,IAAL,GAAYT,GAAZ;A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E,YAAP;AAAqB,aAAGmB;AAAxB,SAAX;AACA;;AAEF,WAAK,CAAL;AACEC,QAAAA,QAAQ,GAAGxC,aAAa,CAACuC,IAAD,CAAxB;AAIA,aAAKb,aAAL,CAAmBqB,oBAAnB;AACA,aAAKrB,aAAL,CAAmBsB,mBAAnB,IAA0CR,QAAQ,CAACT,OAAT,CAAiBzB,MAA3D;;AAEA,aAAK,MAAMyB,OAAX,IAAsBS,QAAQ,CAACT,OAA/B,EAAwC;AACtC,eAAKL,aAAL,CAAmBuB,iBAAnB,IAAwClB,OAAO,CAACzB,MAAhD;AACD;;AACD,aAAKoB,aAAL,CAAmBwB,qBAAnB,IAA4CV,QAAQ,CAACR,IAAT,CAAc1B,MAAd,GAAuBmC,WAAnE;AAEA;;AACF;AACE,cAAM,IAAIL,KAAJ,kCAAoC,KAAKhB,IAAzC,EAAN;AA7BJ;;AAgCA,UAAM+B,MAAmB,GAAG;AAAC/B,MAAAA,IAAI,EAAE,SAAP;AAAkBoB,MAAAA,QAAlB;AAA4BrB,MAAAA,UAAU,EAAE,KAAKA;AAA7C,KAA5B;;AAEA,QAAI,KAAKE,EAAL,KAAY,IAAhB,EAAsB;AACpB8B,MAAAA,MAAM,CAAC9B,EAAP,GAAY,KAAKA,EAAjB;AACD;;AAED,WAAO8B,MAAP;AACD;;AAEDC,EAAAA,mBAAmB,CACjBC,OADiB,EAEJ;AACb,QAAI,OAAOA,OAAP,KAAmB,UAAvB,EAAmC;AACjC,aAAO,KAAKhB,oBAAL,CAA0BgB,OAA1B,CAAP;AACD;;AACD,WAAO,KAAKhB,oBAAL,CAA0BpC,OAA1B,CAAP;AACD;;AA7KoC","sourcesContent":["// This code is forked from https://github.com/mapbox/vector-tile-js under BSD 3-clause license.\n\nimport Protobuf from 'pbf';\nimport {FlatFeature, FlatIndexedGeometry, GeojsonGeometryInfo} from '@loaders.gl/schema';\nimport {classifyRings, project, readFeature} from '../../helpers/binary-util-functions';\n\n// Reduce GC by reusing variables\nlet endPos: number;\nlet cmd: number;\nlet cmdLen: number;\nlet length: number;\nlet x: number;\nlet y: number;\nlet i: number;\n\nexport const TEST_EXPORTS = {\n classifyRings\n};\n\nexport default class VectorTileFeature {\n properties: {[x: string]: string | number | boolean | null};\n extent: any;\n type: number;\n id: number | null;\n _pbf: Protobuf;\n _geometry: number;\n _keys: string[];\n _values: (string | number | boolean | null)[];\n _geometryInfo: GeojsonGeometryInfo;\n\n // eslint-disable-next-line max-params\n constructor(\n pbf: Protobuf,\n end: number,\n extent: any,\n keys: string[],\n values: (string | number | boolean | null)[],\n geometryInfo: GeojsonGeometryInfo\n ) {\n // Public\n this.properties = {};\n this.extent = extent;\n this.type = 0;\n this.id = null;\n\n // Private\n this._pbf = pbf;\n this._geometry = -1;\n this._keys = keys;\n this._values = values;\n this._geometryInfo = geometryInfo;\n\n pbf.readFields(readFeature, this, end);\n }\n\n // eslint-disable-next-line complexity, max-statements\n loadGeometry(): FlatIndexedGeometry {\n const pbf = this._pbf;\n pbf.pos = this._geometry;\n\n endPos = pbf.readVarint() + pbf.pos;\n cmd = 1;\n length = 0;\n x = 0;\n y = 0;\n i = 0;\n\n // Note: I attempted to replace the `data` array with a\n // Float32Array, but performance was worse, both using\n // `set()` and direct index access. Also, we cannot\n // know how large the buffer should be, so it would\n // increase memory usage\n const indices: number[] = []; // Indices where geometries start\n const data: number[] = []; // Flat array of coordinate data\n\n while (pbf.pos < endPos) {\n if (length <= 0) {\n cmdLen = pbf.readVarint();\n cmd = cmdLen & 0x7;\n length = cmdLen >> 3;\n }\n\n length--;\n\n if (cmd === 1 || cmd === 2) {\n x += pbf.readSVarint();\n y += pbf.readSVarint();\n\n if (cmd === 1) {\n // New line\n indices.push(i);\n }\n data.push(x, y);\n i += 2;\n } else if (cmd === 7) {\n // Workaround for https://github.com/mapbox/mapnik-vector-tile/issues/90\n if (i > 0) {\n const start = indices[indices.length - 1]; // start index of polygon\n data.push(data[start], data[start + 1]); // closePolygon\n i += 2;\n }\n } else {\n throw new Error(`unknown command ${cmd}`);\n }\n }\n\n return {data, indices};\n }\n\n /**\n *\n * @param transform\n * @returns result\n */\n _toBinaryCoordinates(transform) {\n // Expands the protobuf data to an intermediate Flat GeoJSON\n // data format, which maps closely to the binary data buffers.\n // It is similar to GeoJSON, but rather than storing the coordinates\n // in multidimensional arrays, we have a 1D `data` with all the\n // coordinates, and then index into this using the `indices`\n // parameter, e.g.\n //\n // geometry: {\n // type: 'Point', data: [1,2], indices: [0]\n // }\n // geometry: {\n // type: 'LineString', data: [1,2,3,4,...], indices: [0]\n // }\n // geometry: {\n // type: 'Polygon', data: [1,2,3,4,...], indices: [[0, 2]]\n // }\n // Thus the indices member lets us look up the relevant range\n // from the data array.\n // The Multi* versions of the above types share the same data\n // structure, just with multiple elements in the indices array\n const geom = this.loadGeometry();\n let geometry;\n\n // Apply the supplied transformation to data\n transform(geom.data, this);\n\n const coordLength = 2;\n\n // eslint-disable-next-line default-case\n switch (this.type) {\n case 1: // Point\n this._geometryInfo.pointFeaturesCount++;\n this._geometryInfo.pointPositionsCount += geom.indices.length;\n geometry = {type: 'Point', ...geom};\n break;\n\n case 2: // LineString\n this._geometryInfo.lineFeaturesCount++;\n this._geometryInfo.linePathsCount += geom.indices.length;\n this._geometryInfo.linePositionsCount += geom.data.length / coordLength;\n geometry = {type: 'LineString', ...geom};\n break;\n\n case 3: // Polygon\n geometry = classifyRings(geom);\n\n // Unlike Point & LineString geom.indices is a 2D array, thanks\n // to the classifyRings method\n this._geometryInfo.polygonFeaturesCount++;\n this._geometryInfo.polygonObjectsCount += geometry.indices.length;\n\n for (const indices of geometry.indices) {\n this._geometryInfo.polygonRingsCount += indices.length;\n }\n this._geometryInfo.polygonPositionsCount += geometry.data.length / coordLength;\n\n break;\n default:\n throw new Error(`Invalid geometry type: ${this.type}`);\n }\n\n const result: FlatFeature = {type: 'Feature', geometry, properties: this.properties};\n\n if (this.id !== null) {\n result.id = this.id;\n }\n\n return result;\n }\n\n toBinaryCoordinates(\n options: {x: number; y: number; z: number} | ((data: number[], feature: {extent: any}) => void)\n ): FlatFeature {\n if (typeof options === 'function') {\n return this._toBinaryCoordinates(options);\n }\n return this._toBinaryCoordinates(project);\n }\n}\n"],"file":"vector-tile-feature.js"}
|
|
1
|
+
{"version":3,"sources":["../../../../src/lib/binary-vector-tile/vector-tile-feature.ts"],"names":["classifyRings","project","readFeature","endPos","cmd","cmdLen","length","x","y","i","TEST_EXPORTS","VectorTileFeature","constructor","pbf","end","extent","keys","values","geometryInfo","properties","type","id","_pbf","_geometry","_keys","_values","_geometryInfo","readFields","loadGeometry","pos","readVarint","indices","data","readSVarint","push","start","Error","_toBinaryCoordinates","transform","geom","geometry","coordLength","pointFeaturesCount","pointPositionsCount","lineFeaturesCount","linePathsCount","linePositionsCount","polygonFeaturesCount","polygonObjectsCount","polygonRingsCount","polygonPositionsCount","result","toBinaryCoordinates","options","z","size","Math","pow","x0","y0"],"mappings":";AAIA,SAAQA,aAAR,EAAuBC,OAAvB,EAAgCC,WAAhC,QAAkD,qCAAlD;AAGA,IAAIC,MAAJ;AACA,IAAIC,GAAJ;AACA,IAAIC,MAAJ;AACA,IAAIC,MAAJ;AACA,IAAIC,CAAJ;AACA,IAAIC,CAAJ;AACA,IAAIC,CAAJ;AAEA,OAAO,MAAMC,YAAY,GAAG;AAC1BV,EAAAA;AAD0B,CAArB;AAIP,eAAe,MAAMW,iBAAN,CAAwB;AAYrCC,EAAAA,WAAW,CACTC,GADS,EAETC,GAFS,EAGTC,MAHS,EAITC,IAJS,EAKTC,MALS,EAMTC,YANS,EAOT;AAAA;;AAAA;;AAAA;;AAAA;;AAAA;;AAAA;;AAAA;;AAAA;;AAAA;;AAEA,SAAKC,UAAL,GAAkB,EAAlB;AACA,SAAKJ,MAAL,GAAcA,MAAd;AACA,SAAKK,IAAL,GAAY,CAAZ;AACA,SAAKC,EAAL,GAAU,IAAV;AAGA,SAAKC,IAAL,GAAYT,GAAZ;AACA,SAAKU,SAAL,GAAiB,CAAC,CAAlB;A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AAK6B,oBAAL,CAA2BL,IAAD,IAAoB/B,OAAO,CAAC+B,IAAD,EAAO0B,EAAP,EAAWC,EAAX,EAAeJ,IAAf,CAArD,CAAP;AACD;;AAlLoC","sourcesContent":["// This code is forked from https://github.com/mapbox/vector-tile-js under BSD 3-clause license.\n\nimport Protobuf from 'pbf';\nimport {FlatFeature, FlatIndexedGeometry, GeojsonGeometryInfo} from '@loaders.gl/schema';\nimport {classifyRings, project, readFeature} from '../../helpers/binary-util-functions';\n\n// Reduce GC by reusing variables\nlet endPos: number;\nlet cmd: number;\nlet cmdLen: number;\nlet length: number;\nlet x: number;\nlet y: number;\nlet i: number;\n\nexport const TEST_EXPORTS = {\n classifyRings\n};\n\nexport default class VectorTileFeature {\n properties: {[x: string]: string | number | boolean | null};\n extent: any;\n type: number;\n id: number | null;\n _pbf: Protobuf;\n _geometry: number;\n _keys: string[];\n _values: (string | number | boolean | null)[];\n _geometryInfo: GeojsonGeometryInfo;\n\n // eslint-disable-next-line max-params\n constructor(\n pbf: Protobuf,\n end: number,\n extent: any,\n keys: string[],\n values: (string | number | boolean | null)[],\n geometryInfo: GeojsonGeometryInfo\n ) {\n // Public\n this.properties = {};\n this.extent = extent;\n this.type = 0;\n this.id = null;\n\n // Private\n this._pbf = pbf;\n this._geometry = -1;\n this._keys = keys;\n this._values = values;\n this._geometryInfo = geometryInfo;\n\n pbf.readFields(readFeature, this, end);\n }\n\n // eslint-disable-next-line complexity, max-statements\n loadGeometry(): FlatIndexedGeometry {\n const pbf = this._pbf;\n pbf.pos = this._geometry;\n\n endPos = pbf.readVarint() + pbf.pos;\n cmd = 1;\n length = 0;\n x = 0;\n y = 0;\n i = 0;\n\n // Note: I attempted to replace the `data` array with a\n // Float32Array, but performance was worse, both using\n // `set()` and direct index access. Also, we cannot\n // know how large the buffer should be, so it would\n // increase memory usage\n const indices: number[] = []; // Indices where geometries start\n const data: number[] = []; // Flat array of coordinate data\n\n while (pbf.pos < endPos) {\n if (length <= 0) {\n cmdLen = pbf.readVarint();\n cmd = cmdLen & 0x7;\n length = cmdLen >> 3;\n }\n\n length--;\n\n if (cmd === 1 || cmd === 2) {\n x += pbf.readSVarint();\n y += pbf.readSVarint();\n\n if (cmd === 1) {\n // New line\n indices.push(i);\n }\n data.push(x, y);\n i += 2;\n } else if (cmd === 7) {\n // Workaround for https://github.com/mapbox/mapnik-vector-tile/issues/90\n if (i > 0) {\n const start = indices[indices.length - 1]; // start index of polygon\n data.push(data[start], data[start + 1]); // closePolygon\n i += 2;\n }\n } else {\n throw new Error(`unknown command ${cmd}`);\n }\n }\n\n return {data, indices};\n }\n\n /**\n *\n * @param transform\n * @returns result\n */\n _toBinaryCoordinates(transform) {\n // Expands the protobuf data to an intermediate Flat GeoJSON\n // data format, which maps closely to the binary data buffers.\n // It is similar to GeoJSON, but rather than storing the coordinates\n // in multidimensional arrays, we have a 1D `data` with all the\n // coordinates, and then index into this using the `indices`\n // parameter, e.g.\n //\n // geometry: {\n // type: 'Point', data: [1,2], indices: [0]\n // }\n // geometry: {\n // type: 'LineString', data: [1,2,3,4,...], indices: [0]\n // }\n // geometry: {\n // type: 'Polygon', data: [1,2,3,4,...], indices: [[0, 2]]\n // }\n // Thus the indices member lets us look up the relevant range\n // from the data array.\n // The Multi* versions of the above types share the same data\n // structure, just with multiple elements in the indices array\n const geom = this.loadGeometry();\n let geometry;\n\n // Apply the supplied transformation to data\n transform(geom.data, this);\n\n const coordLength = 2;\n\n // eslint-disable-next-line default-case\n switch (this.type) {\n case 1: // Point\n this._geometryInfo.pointFeaturesCount++;\n this._geometryInfo.pointPositionsCount += geom.indices.length;\n geometry = {type: 'Point', ...geom};\n break;\n\n case 2: // LineString\n this._geometryInfo.lineFeaturesCount++;\n this._geometryInfo.linePathsCount += geom.indices.length;\n this._geometryInfo.linePositionsCount += geom.data.length / coordLength;\n geometry = {type: 'LineString', ...geom};\n break;\n\n case 3: // Polygon\n geometry = classifyRings(geom);\n\n // Unlike Point & LineString geom.indices is a 2D array, thanks\n // to the classifyRings method\n this._geometryInfo.polygonFeaturesCount++;\n this._geometryInfo.polygonObjectsCount += geometry.indices.length;\n\n for (const indices of geometry.indices) {\n this._geometryInfo.polygonRingsCount += indices.length;\n }\n this._geometryInfo.polygonPositionsCount += geometry.data.length / coordLength;\n\n break;\n default:\n throw new Error(`Invalid geometry type: ${this.type}`);\n }\n\n const result: FlatFeature = {type: 'Feature', geometry, properties: this.properties};\n\n if (this.id !== null) {\n result.id = this.id;\n }\n\n return result;\n }\n\n toBinaryCoordinates(\n options: {x: number; y: number; z: number} | ((data: number[], feature: {extent: any}) => void)\n ): FlatFeature {\n if (typeof options === 'function') {\n return this._toBinaryCoordinates(options);\n }\n const {x, y, z} = options;\n const size = this.extent * Math.pow(2, z);\n const x0 = this.extent * x;\n const y0 = this.extent * y;\n\n return this._toBinaryCoordinates((data: number[]) => project(data, x0, y0, size));\n }\n}\n"],"file":"vector-tile-feature.js"}
|
package/dist/esm/mvt-loader.js
CHANGED
|
@@ -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,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,SAA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AAI,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"}
|
|
@@ -146,7 +146,11 @@ class VectorTileFeature {
|
|
|
146
146
|
if (typeof options === 'function') {
|
|
147
147
|
return this._toBinaryCoordinates(options);
|
|
148
148
|
}
|
|
149
|
-
|
|
149
|
+
const { x, y, z } = options;
|
|
150
|
+
const size = this.extent * Math.pow(2, z);
|
|
151
|
+
const x0 = this.extent * x;
|
|
152
|
+
const y0 = this.extent * y;
|
|
153
|
+
return this._toBinaryCoordinates((data) => (0, binary_util_functions_1.project)(data, x0, y0, size));
|
|
150
154
|
}
|
|
151
155
|
}
|
|
152
156
|
exports.default = VectorTileFeature;
|
package/dist/mvt-worker.js
CHANGED
|
@@ -1699,7 +1699,11 @@
|
|
|
1699
1699
|
if (typeof options === "function") {
|
|
1700
1700
|
return this._toBinaryCoordinates(options);
|
|
1701
1701
|
}
|
|
1702
|
-
|
|
1702
|
+
const { x: x2, y: y2, z } = options;
|
|
1703
|
+
const size = this.extent * Math.pow(2, z);
|
|
1704
|
+
const x0 = this.extent * x2;
|
|
1705
|
+
const y0 = this.extent * y2;
|
|
1706
|
+
return this._toBinaryCoordinates((data) => project(data, x0, y0, size));
|
|
1703
1707
|
}
|
|
1704
1708
|
};
|
|
1705
1709
|
|
|
@@ -2105,7 +2109,7 @@
|
|
|
2105
2109
|
}
|
|
2106
2110
|
|
|
2107
2111
|
// src/mvt-loader.ts
|
|
2108
|
-
var VERSION = true ? "3.1.
|
|
2112
|
+
var VERSION = true ? "3.1.8" : "latest";
|
|
2109
2113
|
var MVTWorkerLoader = {
|
|
2110
2114
|
name: "Mapbox Vector Tile",
|
|
2111
2115
|
id: "mvt",
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@loaders.gl/mvt",
|
|
3
3
|
"description": "Loader for Mapbox Vector Tiles",
|
|
4
|
-
"version": "3.1.
|
|
4
|
+
"version": "3.1.8",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"publishConfig": {
|
|
7
7
|
"access": "public"
|
|
@@ -32,14 +32,14 @@
|
|
|
32
32
|
"build-worker": "esbuild src/workers/mvt-worker.ts --bundle --outfile=dist/mvt-worker.js --define:__VERSION__=\\\"$npm_package_version\\\""
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@loaders.gl/gis": "3.1.
|
|
36
|
-
"@loaders.gl/loader-utils": "3.1.
|
|
37
|
-
"@loaders.gl/schema": "3.1.
|
|
35
|
+
"@loaders.gl/gis": "3.1.8",
|
|
36
|
+
"@loaders.gl/loader-utils": "3.1.8",
|
|
37
|
+
"@loaders.gl/schema": "3.1.8",
|
|
38
38
|
"@math.gl/polygon": "^3.5.1",
|
|
39
39
|
"pbf": "^3.2.1"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
42
|
"@types/pbf": "^3.0.2"
|
|
43
43
|
},
|
|
44
|
-
"gitHead": "
|
|
44
|
+
"gitHead": "0ef07b4e9fc20f5a882224cf241c6fd1bad898d8"
|
|
45
45
|
}
|
|
@@ -189,6 +189,11 @@ export default class VectorTileFeature {
|
|
|
189
189
|
if (typeof options === 'function') {
|
|
190
190
|
return this._toBinaryCoordinates(options);
|
|
191
191
|
}
|
|
192
|
-
|
|
192
|
+
const {x, y, z} = options;
|
|
193
|
+
const size = this.extent * Math.pow(2, z);
|
|
194
|
+
const x0 = this.extent * x;
|
|
195
|
+
const y0 = this.extent * y;
|
|
196
|
+
|
|
197
|
+
return this._toBinaryCoordinates((data: number[]) => project(data, x0, y0, size));
|
|
193
198
|
}
|
|
194
199
|
}
|