11import Pbf from 'pbf' ;
2- import { type GeoJSONOptions , type Feature , GeoJSONWrapper } from ' ./lib/geojson_wrapper' ;
2+ import { type Feature , GEOJSON_TILE_LAYER_NAME , type GeoJSONOptions , GeoJSONWrapper } from " ./lib/geojson_wrapper" ;
33import geojsonvt from 'geojson-vt' ;
4- import { type VectorTileLayer , type VectorTile , VectorTileFeature } from '@mapbox/vector-tile ' ;
4+ import type { VectorTileFeatureLike , VectorTileLike , VectorTileLayerLike } from './lib/types ' ;
55
66interface Context {
77 keys : string [ ] ;
88 values : ( string | boolean | number ) [ ] ;
99 keycache : Record < string , number > ;
1010 valuecache : Record < string , number > ;
11- feature ?: VectorTileFeature ;
11+ feature ?: VectorTileFeatureLike ;
1212}
1313
1414/**
@@ -17,7 +17,7 @@ interface Context {
1717 * @param tile
1818 * @return uncompressed, pbf-serialized tile data
1919 */
20- export function fromVectorTileJs ( tile : VectorTile ) : Uint8Array {
20+ export function fromVectorTileJs ( tile : VectorTileLike ) : Uint8Array {
2121 const out = new Pbf ( ) ;
2222 writeTile ( tile , out ) ;
2323 return out . finish ( ) ;
@@ -31,7 +31,7 @@ export function fromVectorTileJs(tile: VectorTile): Uint8Array {
3131 * @return uncompressed, pbf-serialized tile data
3232 */
3333export function fromGeojsonVt ( layers : geojsonvt . Tile [ ] , options ?: GeoJSONOptions ) : Uint8Array {
34- const l : Record < string , VectorTileLayer > = { } ;
34+ const l : Record < string , VectorTileLayerLike > = { } ;
3535 // eslint-disable-next-line @typescript-eslint/no-for-in-array
3636 for ( const k in layers ) {
3737 l [ k ] = new GeoJSONWrapper ( layers [ k ] . features , options ) ;
@@ -42,13 +42,13 @@ export function fromGeojsonVt(layers: geojsonvt.Tile[], options?: GeoJSONOptions
4242 return fromVectorTileJs ( { layers : l } ) ;
4343}
4444
45- function writeTile ( tile : VectorTile , pbf : Pbf ) {
45+ function writeTile ( tile : VectorTileLike , pbf : Pbf ) {
4646 for ( const key in tile . layers ) {
4747 pbf . writeMessage ( 3 , writeLayer , tile . layers [ key ] ) ;
4848 }
4949}
5050
51- function writeLayer ( layer : VectorTileLayer , pbf : Pbf ) {
51+ function writeLayer ( layer : VectorTileLayerLike , pbf : Pbf ) {
5252 pbf . writeVarintField ( 15 , layer . version || 1 ) ;
5353 pbf . writeStringField ( 1 , layer . name || '' ) ;
5454 pbf . writeVarintField ( 5 , layer . extent || 4096 ) ;
@@ -128,7 +128,7 @@ function zigzag(num: number) {
128128 return ( num << 1 ) ^ ( num >> 31 ) ;
129129}
130130
131- function writeGeometry ( feature : VectorTileFeature , pbf : Pbf ) {
131+ function writeGeometry ( feature : VectorTileFeatureLike , pbf : Pbf ) {
132132 const geometry = feature . loadGeometry ( ) ;
133133 const type = feature . type ;
134134 let x = 0 ;
@@ -179,5 +179,9 @@ function writeValue(value: string | boolean | number, pbf: Pbf) {
179179export {
180180 GeoJSONWrapper ,
181181 GeoJSONOptions ,
182- Feature
183- }
182+ Feature ,
183+ GEOJSON_TILE_LAYER_NAME ,
184+ VectorTileFeatureLike ,
185+ VectorTileLike ,
186+ VectorTileLayerLike ,
187+ } ;
0 commit comments