MBTiles规范说明 中文版

MBtiles

MbTiles 是一个用于在 sqllite 数据库中存储任意瓦片地图数据用于即时使用和高效传输的规范。
MBtiles 文件称为做tilesets(图块集),必须执行以下规范,确保与设备的兼容性。

版本号

规范有1.0,1.1,1.2,1.3 现在最新执行的是1.3标准。

  • v1.3 现在执行的标准。老版本作为历史参考。
  • v1.2,v1.1,v1.0 过去起草的标准,可以看到内容的细化的过程。

概念

MBTiles 是一个简捷的限制性规范,只支持矢量或图像瓦片以及交互性网格瓦片,使用球形墨卡托投影,元数据使用经纬度坐标,如边界、坐标等。

这是最低要求,仅指定必须可检索数据的方式。因此,MBTiles 文件可以在内部压缩和优化数据,并构建符合 MBTiles 规范的视图。
与 Spatialite,GeoJSON 和 Rasterlite 不同,MBTiles 不是原始数据存储。它用于存储切片数据,例如渲染的地图切片。

UTFGrid

MBTiles 规范以前包含 UTFGrid 规范。 它已在 1.2 版中删除,并通过同步的版本号移入其自己的规范,因此 MBTiles 1.2 与 UTFGrid 1.2 兼容。 这些规范集成在一起,但彼此之间不需要相互遵循。

许可

规范的文本根据美国知识共享署名 3.0 许可协议获得许可。但是,在产品和代码中完全免费使用此规范:没有使用费,限制或要求。

v1.3

Compatibility兼容性说明

因为使用视图也可以生成符合规范的数据,两种实现可能会存储具有不同内部细节的瓦片,这意味着一种实现可能无法添加到现有文件中。
作为数据格式,MBTiles 可以存储任何瓦片数据,因此可以存储无法执行任何操作的数据。
依赖规范中未定义的元数据键可能会导致兼容性问题。

数据库版本要求

Tilesets 使用 3.0.0 或更高版本的有效 SQLite 数据库。只要求核心 SQLite 功能; tileset 不需要扩展。
MBTiles databases can optionally use the officially assigned magic number to be easily identified as MBTiles.[1.2]

数据库

注意:概述的架构应作为接口遵循。产生兼容结果的 SQLite 视图同样有效。为了方便起见,本规范将表和虚拟表(视图)称为表。

Charset 字符集

mbtiles 瓦片集中的表的文本列中的所有文本都必须编码为 UTF-8。

Metadata 元数据

结构

该数据库必须包含一个名为metadata的表或视图。
该表必须包含两个名为 namevalue 的列。metadata表的典型 create 语句:

CREATE table metadata (name text, value text);
内容

The metadata 表使用 key/value store for settings. 必须包含以下2个字段:

  • name (string): The human-readable name of the tileset.
  • format (string): The file format of the tile data: pbf, jpg, png, webp, or an IETF media type for other formats.

pbf as a format refers to gzip-compressed vector tile data in
Mapbox Vector Tile format.

The metadata 表需要包含下面 4行:

  • bounds (string of comma-separated numbers): The maximum extent of the rendered map area. Bounds 必须 define an area covered by all zoom levels. The bounds are represented as WGS 84
    latitude and longitude values, in the OpenLayers Bounds format
    (left, bottom, right, top). For example, the bounds of the full Earth, minus the poles, would be:
    -180.0,-85,180,85.
  • center (string of comma-separated numbers): 地图默认的经纬、级别中心位置. 如: -122.1906,37.7599,11
  • minzoom (number): the tileset 提供数据的最小级别
  • maxzoom (number): the tileset 提供数据的最大级别

The metadata 表可以包含以下4行:

  • attribution (HTML string): An attribution string, which explains the sources of
    data and/or style for the map.
  • description (string): 描述瓦片集的内容.
  • type (string): 类型overlay or baselayer
  • version (number): 瓦片集的版本.
    This refers to a revision of the tileset itself, not of the MBTiles specification.

如果 the format is pbf, the metadata 表 必须包含下面的字段:

  • json (stringified JSON object): Lists the layers that appear in the vector tiles and the names and types of
    the attributes of features that appear in those layers. See below for more detail.

The metadata 表 可以包含additional rows for tilesets that implement
UTFGrid-based interaction or for
other purposes.

Tiles 瓦片

结构

数据库必须包含一个表 named tiles.

The 表 必须包含三行 one of type integer, named zoom_level, tile_column,
tile_row, and one of type blob, named tile_data.
A typical create statement for the tiles 表:

    CREATE table tiles (zoom_level integer, tile_column integer, tile_row integer, tile_data blob);

数据库可以包含一个索引提高访问性能:

    CREATE UNIQUE INDEX tile_index on tiles (zoom_level, tile_column, tile_row);
内容

The tiles 表包含瓦片和用于定位它们的值.
The zoom_level, tile_column, and tile_row 字段必须 encode the location of the tile, following the
Tile Map Service Specification,
with the restriction that
the global-mercator (aka Spherical Mercator) profile 必须被使用.

注意:使用 TMS tiling scheme, 请求单个瓦片的y轴与 URL 中常用的“XYZ”坐标系相反,所以通常称为 11/327/791 的瓦片插入为 zoom_level 11、tile_column 327 和 tile_row 1256,因为 1256=2^11 - 1 - 791。.

The tile_data 字段 必须包含the raw binary image or vector tile data
for the associated tile as a blob.

Grids

See the UTFGrid specification for
implementation details of grids and interaction metadata itself: the MBTiles
specification is only concerned with storage.

结构

数据库 可以 have 表 named grids and grid_data.

The grids 表 必须包含three 字段 of type integer, named zoom_level, tile_column,
and tile_row, and one of type blob, named grid.
A typical create statement for the grids 表:

    CREATE table grids (zoom_level integer, tile_column integer, tile_row integer, grid blob);

The grid_data 表 必须包含three 字段 of type integer, named zoom_level, tile_column,
and tile_row, and two of type text, named key_name, and key_json.
A typical create statement for the grid_data 表:

    CREATE table grid_data (zoom_level integer, tile_column integer, tile_row integer, key_name text, key_json text);
内容

The grids 表, 如果提供, 必须包含UTFGrid data, compressed in gzip format.

The grid_data 表, 如果提供, 必须包含grid key to value mappings, with values encoded
as JSON objects.

Vector tileset metadata

As mentioned above, Mapbox Vector Tile tilesets 必须 include a json row in the metadata
to summarize what layers are available in the tiles and what attributes are available for the
features in those layers.

The json row, 如果提供,必须包含the UTF-8 string representation of a JSON object.

Vector_layers

The JSON object in the json row 必须包含a vector_layers key, whose value is an array of JSON objects.
Each of those JSON objects describes one layer of vector tile data, and 必须包含the following key-value pairs:

  • id (string): The layer ID, which is referred to as the name of the layer in the Mapbox Vector Tile spec.
  • fields (object): A JSON object whose keys and values are the names and types of attributes available in this layer.
    Each type 必须 be the string "Number", "Boolean", or "String".
    Attributes whose type varies between features SHOULD be listed as "String".

Each layer object 可以包含the following key-value pair:

  • description (string): A human-readable description of the layer’s 内容s.

Each layer object 可以 also包含the following key-value pair:

  • minzoom (number): The lowest zoom level whose tiles this layer appears in.
  • maxzoom (number): The highest zoom level whose tiles this layer appears in.

The minzoom 必须大于或等于 the tileset’s minzoom,
and the maxzoom 必须小于或等于 the tileset’s maxzoom.

These keys are 使用 to describe the situation where different sets of vector layers
appear in different zoom levels of the same tileset, for example in a case where
a “minor roads” layer is only提供 at high zoom levels.

Tilestats

The JSON object in the json row 可以包含a tilestats key, whose value is an object in the “geostats”
format documented in the mapbox-geostats
repository. Like the vector_layers, it lists the tileset’s layers and the attributes found
within each layer, but also gives sample values for each attribute and the range of values for
numeric attributes.

Example示例

A 矢量瓦片集 tileset 包含美国 Census 乡村主干道路 from TIGER might
have the following metadata 表:

  • name: TIGER 2016
  • format: pbf
  • bounds: -179.231086,-14.601813,179.859681,71.441059
  • center: -84.375000,36.466030,5
  • minzoom: 0
  • maxzoom: 5
  • attribution: United States Census
  • description: US Census counties and primary roads
  • type: overlay
  • version: 2
  • json:
    {
        "vector_layers": [
            {
                "id": "tl_2016_us_county",
                "description": "Census counties",
                "minzoom": 0,
                "maxzoom": 5,
                "fields": {
                    "ALAND": "Number",
                    "AWATER": "Number",
                    "GEOID": "String",
                    "MTFCC": "String",
                    "NAME": "String"
                }
            },
            {
                "id": "tl_2016_us_primaryroads",
                "description": "Census primary roads",
                "minzoom": 0,
                "maxzoom": 5,
                "fields": {
                    "FULLNAME": "String",
                    "LINEARID": "String",
                    "MTFCC": "String",
                    "RTTYP": "String"
                }
            }
        ],
        "tilestats": {
            "layerCount": 2,
            "layers": [
                {
                    "layer": "tl_2016_us_county",
                    "count": 3233,
                    "geometry": "Polygon",
                    "attributeCount": 5,
                    "attributes": [
                        {
                            "attribute": "ALAND",
                            "count": 6,
                            "type": "number",
                            "values": [
                                1000508839,
                                1001065264,
                                1001787870,
                                1002071716,
                                1002509543,
                                1003451714
                            ],
                            "min": 82093,
                            "max": 376825063576
                        },
                        {
                            "attribute": "AWATER",
                            "count": 6,
                            "type": "number",
                            "values": [
                                0,
                                100091246,
                                10017651,
                                100334057,
                                10040117,
                                1004128585
                            ],
                            "min": 0,
                            "max": 25190628850
                        },
                        {
                            "attribute": "GEOID",
                            "count": 6,
                            "type": "string",
                            "values": [
                                "01001",
                                "01003",
                                "01005",
                                "01007",
                                "01009",
                                "01011"
                            ]
                        },
                        {
                            "attribute": "MTFCC",
                            "count": 1,
                            "type": "string",
                            "values": [
                                "G4020"
                            ]
                        },
                        {
                            "attribute": "NAME",
                            "count": 6,
                            "type": "string",
                            "values": [
                                "Abbeville",
                                "Acadia",
                                "Accomack",
                                "Ada",
                                "Adair",
                                "Adams"
                            ]
                        }
                    ]
                },
                {
                    "layer": "tl_2016_us_primaryroads",
                    "count": 12509,
                    "geometry": "LineString",
                    "attributeCount": 4,
                    "attributes": [
                        {
                            "attribute": "FULLNAME",
                            "count": 6,
                            "type": "string",
                            "values": [
                                "1- 80",
                                "10",
                                "10-Hov Fwy",
                                "12th St",
                                "14 Th St",
                                "17th St NE"
                            ]
                        },
                        {
                            "attribute": "LINEARID",
                            "count": 6,
                            "type": "string",
                            "values": [
                                "1101000363000",
                                "1101000363004",
                                "1101019172643",
                                "1101019172644",
                                "1101019172674",
                                "1101019172675"
                            ]
                        },
                        {
                            "attribute": "MTFCC",
                            "count": 1,
                            "type": "string",
                            "values": [
                                "S1100"
                            ]
                        },
                        {
                            "attribute": "RTTYP",
                            "count": 6,
                            "type": "string",
                            "values": [
                                "C",
                                "I",
                                "M",
                                "O",
                                "S",
                                "U"
                            ]
                        }
                    ]
                }
            ]
        }
    }

未来方向

在未来版本,“metadata”表会包含一个“compression”行去描述tiledata使用的压缩方式。
在未来版本,“metadata”表的“bounds”,“minzoom”,“maxzoom” 作为必填项目。
在未来版本会删除“metadata”表的“json”这一行描述。

  • 0
    点赞
  • 10
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值