jptilesclient
TypeScript icon, indicating that this package has built-in type declarations

2.0.1 • Public • Published

Ver.2 になったことにより、破壊的な変更が行われています。

ver.1 のクライアントはLegacyClientとして利用できます

地理院地図 Vector(仮称)用クライアント

国土地理院が試験提供している地理院地図 Vector(仮称)のベクトルタイルを非常に扱い安くするライブラリです。
他のベクトルタイルと異なり、Pbf 形式で配布されているため通常は Json のようにデータを扱うことができませんが、
このライブラリを使うことで指定した範囲内のタイルをまとめて一つの GeoJson 形式のオブジェクトとして出力できます。
内部に僕が作ったのsimpletileclientを使っています

使用例

import { writeFileSync } from "fs";
import { VectorClient } from "jptilesclient";

const client = new VectorClient();
const all = [
  "symbol",
  "building",
  "waterarea",
  "boundary",
  "coastline",
  "elevation",
  "label",
  "other",
  "railway",
  "river",
  "road",
];

client.getTileByRect(11, 1819, 806, 5, 5).then((tiles) => {
  writeFileSync("test.geojson", JSON.stringify(tiles.get(all, 5)));
});

このプログラムでは東京のタイルを中心として正方形状に 5*5 マスのタイルを取得し、GeoJson 形式に変換して
test.geojsonというファイル名で保存しています。
この作成したファイルは QGIS などのソフトで閲覧することが可能です。

API

Constructor


new VectorClient() —タイルを取得するクライアントを作成する。
このクライアントのメソッドを使ってタイルを取得、変換できる

Method


getTile(zoom: number, x: number, y: number)=>Promise
cx,cyのタイルを取得し、それらを加工し、GeoJson にするためのTileManagerのインスタンスを返します。

getByRect(zoom: number, cx: number, cy: number, width: number,
height: number,sourceLayers: string | string[])=>Promise

cx,cyを中心として幅width,高さheightの範囲のタイルを全取得し、それらを加工し、GeoJson にするためのTileManagerのインスタンスを返します。

TileManager

get(sourceLayers: string | string[], precision?: number)=>GeoJsonsourceLayersで指定したレイヤーのみを GeoJson にして返します。また、オプションでデータに含まれている経度、緯度の精度をprecisionで指定した桁まで落とすことができます。

Readme

Keywords

none

Package Sidebar

Install

npm i jptilesclient

Weekly Downloads

0

Version

2.0.1

License

ISC

Unpacked Size

16.7 kB

Total Files

11

Last publish

Collaborators

  • inaridiy