- Notifications
You must be signed in to change notification settings - Fork0
This library reads/writes PMTiles V3.0 as well as S2PMTiles V1.0
License
Open-S2/s2-pmtiles
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
A Modified TypeScript implementation of thePMTiles library. It is backwards compatible but offers support for the S2 Projection.
For now this spec supports deflating metadata/directories inside the browser, but it will be removed in the future.
#bunbun add s2-pmtiles# pnpmpnpm add s2-pmtiles# yarnyarn add s2-pmtiles# npmnpm install s2-pmtiles# cargocargo install s2-pmtiles
import{S2PMTilesReader,S2PMTilesWriter,TileType}from's2-pmtiles'import{FileReader,FileWriter}from's2-pmtiles/file';// The File Reader you can run on bun/node/denoconsttestFixture1=newS2PMTilesReader(newFileReader('test/fixtures/test_fixture_1.pmtiles'));// get an WM tileletx=0;lety=0;letz=0;letface=0;testFixture1.getTile(x,y,z);// undefied | Uint8Array// get an S2 tiletestFixture1.getTileS2(face,x,y,z);// undefined | Uint8Array// The File Writer you can run on bun/node/denoconsttestFixture2=newS2PMTilesWriter(newFileWriter('tmpFile.pmtiles'),TileType.Pbf);// write a tiletestFixture2.writeTileXYZ(x,y,z,Uint8Array.from([]));// write an S2 tiletestFixture2.writeTileS2(face,x,y,z,Uint8Array.from([]));// when you finish you commit to build the metadatatestFixture2.commit();// The File Reader you can run in the browserimport{S2PMTilesReader}from's2-pmtiles';// you want to add a true after the path for generic PMTiles, as it ensures 206 byte requests.constbrowserFixture=newS2PMTilesReader('https://www.example.com/test.pmtiles',true);// get an WM tilebrowserFixture.getTile(x,y,z);// undefied | Uint8Array// get an S2 tilebrowserFixture.getTileS2(face,x,y,z);// undefined | Uint8Array
Some tsconfigs might need some extra help to see thes2-pmtiles/file
ors2-pmtiles/mmap
package.
To fix this update your tsconfig.json with the following:
{"compilerOptions": {"baseUrl":"./","paths": {"s2-pmtiles/file": ["./node_modules/s2-pmtiles/dist/file.d.ts"],"s2-pmtiles/mmap": ["./node_modules/s2-pmtiles/dist/mmap.d.ts"] } }}
You need the tooltarpaulin
to generate the coverage report. Install it using the following command:
cargo install cargo-tarpaulin
Thebacon coverage
tool is used to generate the coverage report. To utilize thepycobertura package for a prettier coverage report, install it using the following command:
pip install pycobertura
To run the tests, use the following command:
# TYPESCRIPT## basic testbun runtest## live testingbun run test:dev# RUST## basic testcargotest# live testingbacontest
To generate the coverage report, use the following command:
cargo tarpaulin# baconbacon coverage# or type `l` inside the tool