LoginSignup
3
3

More than 5 years have passed since last update.

GeoJSONタイルのフォーマットの違い(TileLayer.GeoJSON vs Tangram)

Posted at

TileLayer.GeoJSON が扱っている GeoJSON タイルは、FeatureCollection がそのまま格納されたものであるが、Tangram が扱う GeoJSON タイルの形式は、これとは異なる。前者を plain GeoJSON tile と呼び、後者を Mapzen/OSM.US-style GeoJSON tile と呼ぶことにする。

「Mapzen/OSM.US-style GeoJSON vector tiles」という書き方は、tamgram の src/tile_source.js が原典である。

/**
 Mapzen/OSM.US-style GeoJSON vector tiles
 @class GeoJSONTileSource
*/
export class GeoJSONTileSource extends NetworkTileSource {

    constructor (source) {
        super(source);
        this.type = 'GeoJSONTileSource';
    }

    parseTile (tile, response) {
        tile.layers = JSON.parse(response);

        TileSource.projectTile(tile); // mercator projection
        TileSource.scaleTile(tile); // re-scale from meters to local tile coords
    }
}

plain GeoJSON tile

プレインな GeoJSON FeatureCollection がそのまま入っている。国土地理院ベクトルタイル提供実験のタイルがこれ。

サンプル: http://cyberjapandata.gsi.go.jp/xyz/experimental_fgd/18/233118/102883.geojson

Mapzen/OSM.US-style GeoJSON tile

サンプル: http://vector.dev.mapzen.com/osm/all/17/116556/51441.json

GeoJSON Feature Collection を、OSM レイヤ名をキーとする JavaScript Object にした形になっている。

仕様は https://github.com/mapzen/vector-datasource/wiki/Mapzen-Vector-Tile-Service に明示されている(Multiple layers in GeoJSON)。

{
   "earth": {
      "type":"FeatureCollection",
      "features": [...],
      ...
   },
   "landuse": {
      "type":"FeatureCollection",
      "features": [...],
      ...
   }
}

多分、この方が描画順の整理など簡単なのだからだと思う。Mapzen の styles.yaml とかを見ていると、そのように思う。

間を取り持つには

間を取り持つのに、サーバサイドでダブルにデータを持つのも芸がない。Tangram に plain GeoJSON tile を扱うクラスを追加するのが正統な手段である。Service Worker の変な使い方として、インタラプトした後に変形するということが将来ありえるだろうか。

自分の作業場所

3
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
3