Movatterモバイル変換


[0]ホーム

URL:


  • Preparing search index...
  • The search index is not available
s2-pmtiles - v1.1.1

s2-pmtiles - v1.1.1

s2-pmtiles

GitHub Actions Workflow Statusnpmcratedownloadsbundledocs-tsdocs-rustdoc-coveragecode-coverageDiscord

About

A Modified TypeScript implementation of thePMTiles library. It is backwards compatible but offers support for the S2 Projection.

Read The Spec

s2-pmtiles-spec

For now this spec supports deflating metadata/directories inside the browser, but it will be removed in the future.

Install

#bun
bunadds2-pmtiles
# pnpm
pnpmadds2-pmtiles
# yarn
yarnadds2-pmtiles
# npm
npminstalls2-pmtiles

# cargo
cargoinstalls2-pmtiles

Example use

import {S2PMTilesReader,S2PMTilesWriter,TileType }from's2-pmtiles'
import {FileReader,FileWriter }from's2-pmtiles/file';

// The File Reader you can run on bun/node/deno
consttestFixture1 =newS2PMTilesReader(newFileReader('test/fixtures/test_fixture_1.pmtiles'));
// get an WM tile
letx =0;
lety =0;
letz =0;
letface =0;
testFixture1.getTile(x,y,z);// undefied | Uint8Array
// get an S2 tile
testFixture1.getTileS2(face,x,y,z);// undefined | Uint8Array

// The File Writer you can run on bun/node/deno
consttestFixture2 =newS2PMTilesWriter(newFileWriter('tmpFile.pmtiles'),TileType.Pbf);
// write a tile
testFixture2.writeTileXYZ(x,y,z,Uint8Array.from([]));
// write an S2 tile
testFixture2.writeTileS2(face,x,y,z,Uint8Array.from([]));
// when you finish you commit to build the metadata
testFixture2.commit();


// The File Reader you can run in the browser
import {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 tile
browserFixture.getTile(x,y,z);// undefied | Uint8Array
// get an S2 tile
browserFixture.getTileS2(face,x,y,z);// undefined | Uint8Array

Browser Support

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"]
}
}
}

Development

Requirements

You need the tooltarpaulin to generate the coverage report. Install it using the following command:

cargoinstallcargo-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:

pipinstallpycobertura

Running Tests

To run the tests, use the following command:

# TYPESCRIPT
## basic test
bunruntest
## live testing
bunruntest:dev

# RUST
## basic test
cargotest
# live testing
bacontest

Generating Coverage Report

To generate the coverage report, use the following command:

cargotarpaulin
# bacon
baconcoverage# or type `l` inside the tool

Settings

Member Visibility

On This Page

AboutReadTheSpecInstallDevelopment

[8]ページ先頭

©2009-2025 Movatter.jp