import type { FlatIndexedGeometry } from '@loaders.gl/schema'; import Protobuf from 'pbf'; type GeometryCommand = { type: 'moveto' | 'lineto' | 'closepath'; x: number; y: number; }; export declare function makeMVTGeometryCommandIterator(pbf: Protobuf): IterableIterator; /** * Creates a bounding box from the feature geometry at the current position * @todo - Reparses the entire PBF geometry - replace with a generic bounding box calculation on parsed data? */ export declare function readBoundingBoxFromPBF(pbf: Protobuf): [number, number, number, number]; /** * Extract intermediate Flat GeoJSON * data format, which maps closely to the binary data buffers. * It is similar to GeoJSON, but rather than storing the coordinates * in multidimensional arrays, we have a 1D `data` with all the * coordinates, and then index into this using the `indices` * parameter, e.g. * * geometry: { * type: 'Point', data: [1,2], indices: [0] * } * geometry: { * type: 'LineString', data: [1,2,3,4,...], indices: [0] * } * geometry: { * type: 'Polygon', data: [1,2,3,4,...], indices: [[0, 2]] * } * Thus the indices member lets us look up the relevant range * from the data array. * The Multi* versions of the above types share the same data * structure, just with multiple elements in the indices array */ export declare function loadFlatGeometryFromPBF(pbf: Protobuf): FlatIndexedGeometry; export {}; /** * Load a GeoJSON style Geometry from the raw PBF * function readGeoJSONGeometryFromPBF(pbf): number[][][] { const lines: number[][][] = []; let line: number[][] | undefined; for (const command of makeMVTGeometryCommandIterator(pbf)) { switch (command.type) { case 'moveto': // moveTo if (line) lines.push(line); line = []; if (line) line.push([command.x, command.y]); break; case 'lineto': if (line) line.push([command.x, command.y]); break; case 'closepath': // Workaround for https://github.com/mapbox/mapnik-vector-tile/issues/90 if (line) { line.push(line[0].slice()); // closePolygon } break; default: // just for eslint } } if (line) { lines.push(line); } return lines; } */ //# sourceMappingURL=parse-geometry-from-pbf.d.ts.map