Mapbox、天地图数据下载及在tileserver中的应用

数据下载

数据下载主要使用的工具为 tiler。可以在直接在gitee中下载编译好的版本使用。

tiler使用

首先配置conf.toml。conf.toml模板如下

[app]
    version = "v 0.1.0"
    title = "MapCloud Tiler"
[output]
    #can be mbtiles/file
    format ="mbtiles"
    #the output dir
    directory ="output"
[task]
    #number of fetchers
    workers = 16
    #number of savers
    savepipe = 1

[tm]
    #name for mbtiles
    name = "tdt-ibo_w"
    #max and min level for mbtiles
    min = 0
    max = 10
    #can be pbf/png/jpg
    format = "png"
    #can be xyz/tm
    schema = "xyz"
    #the vector tiles metadata tilejson
    json = "{}"
    #url is the schema url of tiles
    url= "http://t0.tianditu.com/DataServer?T=ibo_w&x={x}&y={y}&l={z}&tk=XXXXXXXXXXXXXXXXXXX"
[[lrs]]
    min = 0
    max = 7
    geojson = "./geojson/global.geojson"
[[lrs]]
    min = 8
    max = 10
    geojson = "./geojson/big_china.geojson"

对以下几个属性做出说明:

json

为了能在tileserver中正常使用,json字段是要配置的。
矢量数据:
例如我们下载mapbox.mapbox-streets-v8数据集,我们先通过mapbox的API(https://api.mapbox.com/v4/(tilesetId).json?access_token={token})获得该数据集的tilejosn,然后将tilejson的vector_layer拷贝到json字段,注意json字段首尾的大括号。示例如下:

{
    "vector_layers": [
        {
            ...
        },
        {
            ...
        },
        ...
    ]
}

栅格数据:
json字段直接写 {}

format

矢量数据设置pfb,栅格数据更具实际情况设置png或者jpg。

url

mapbox
https://api.mapbox.com/v4/{tilesetId}/{z}/{x}/{y}.vector.pbf?sku={sku}&access_token={token}
天地图
http://t0.tianditu.com/DataServer?T={tilesetId}&x={x}&y={y}&l={z}&tk={token}

lrs

设置不同级别的下载范围。

TileServer启动

配置config.json,主要配置style和数据集

{
  "options": {
    "paths": {
      "fonts": "fonts",
      "styles": "styles"
    }
  },
  "styles": {
    "test-style": {
      "style": "osm-bright/style.json",
      "tilejson": {
        "type": "overlay",
        "bounds": [8.529446, 47.364758, 8.55232, 47.380539]
      }
    },
    "klokantech-basic": {
      "style": "klokantech-basic/style.json",
      "tilejson": {
        "type": "overlay",
        "bounds": [8.529446, 47.364758, 8.55232, 47.380539]
      }
    },
    "dark_matter": {
      "style": "dark_matter/style.json",
      "tilejson": {
        "type": "overlay"
      }
    },
    "outdoors": {
      "style": "Outdoors/style.json",
      "tilejson": {
        "type": "overlay"
      }
    }
  },
  "data": {   
    "streets-v8": {
      "mbtiles": "streets-v8-z0-13.mbtiles"
    },
    "terrain-v2": {
      "mbtiles": "terrain-v2-z0-11.mbtiles"
    },
    "tdt-ibo_w": {
      "mbtiles": "tiandi_ibo-z0-10.mbtiles"
    },
   "tdt-cva_w": {
      "mbtiles": "tiandi_cva-z0-13.mbtiles"
    }
  }
}

配置style

style 中数据集配置示例如下

"sources": {
        "composite": {
            "url": "mbtiles://{streets-v8}",
            "type": "vector"
        },
        "terrain": {
            "url": "mbtiles://{terrain-v2}",
            "type": "vector"
        },
        "tdt-ibo_w": {
            "url": "mbtiles://{tdt-ibo_w}",
            "type": "raster"
        },
    "tdt-cva_w": {
            "url": "mbtiles://{tdt-cva_w}",
            "type": "raster"
        }
    },

你可能感兴趣的:(Mapbox、天地图数据下载及在tileserver中的应用)