MBTiles and SMTiles format map tiles

Feedback


SuperMap iServer supports the map tiles that conform with MBTiles standard and an extended format based on MBTiles, SMTiles. MBTiles is a kind of standard made by MapBox that stores map tile data to SQLite database to use, manage and share.

Please refer to http://mapbox.com/mbtiles-spec/ for more information about MBTiles.

 

MBTiles

MBTiles formats require the map coordinate system is: Web Mercator, namely the PCS_WGS_1984_WORLD_MERCATOR, EPSG Code: 3857. MBTiles creates and organizes the map tiles according to TMS of  OSGeo, supporting the fixed scale set in Web Mercator. As shown in table 1, the initialization display level 0 in this scale contains a 256*256 tile, and define the origin point is (-20037508.34,-20037508.34), that is, the left bottom of global. MBTiles supports PNG and JPG.

Table 1 Parameter list of MBTiles display levels

Display Level Map width and height (pixel) Tile number Ground resolution (m/pixel) map scale (96 dpi)
0 256 1 156543.033928 1:591658710.909131
1 512 4 78271.516964 1:591658710.909131
2 1024 16 39135.758482 1:147914677.727283
3 2048 64 19567.879241 1:73957338.863641
4 4096 256 9783.939621 1:36978669.431821
5 8192 1024 4891.969810 1:18489334.715910
6 16384 4096 2445.984905 1:9244667.357955
7 32768 16384 1222.992453 1:4622333.678978
8 65536 65536 611.496226 1:2311166.839489
9 131072 262144 305.748113 1:1155583.419744
10 262144 1048576 152.874057 1:577791.709872
11 524288 4194304 76.437028 1:288895.854936
12 1048576 16777216 38.218514 1:144447.927468
13 2097152 67108864 19.109257 1:72223.963734
14 4194304 268435456 9.554629 1:36111.981867
15 8388608 1073741824 4.777314 1:18055.990934
16 16777216 4294967296 2.388657 1:9027.995467
17 33554432 17179869184 1.194329 1:4513.997733
18 67108864 68719476736 0.597164 1:2256.998867
19 134217728 274877906944 0.298582 1:1128.499433
20 268435456 1099511627776 0.149291 1:564.249717
21 536870912 4398046511104 0.074646 1:282.124858
22 1073741824 17592186044416 0.037323 1:141.062429

The map tile storage format of MBTiles *.mbtiles file name is composed by map name, Hashcode, tile width and height, tile format, T (transparent) and .mbtiles suffix, such as China_69470548_256X256_PNG_T.mbtiles and China_69470548_256X256_PNG.mbtiles.

SMTiles

In order to meet the application requirements, SuperMap iServer not only supports to create and use the MBTiles tile map data, but also supports the SMTiles whihc is extended on MBTiles. Compared to MBTiles format, SMTiles supports any coordinate system and scale. The start point of tile should be any specified point. The directory of row increase from origin to left bottom. In addition, map tile format supports PNG, JPG, PNG and JPG.

The map tile storage format of SMTiles *.smtiles file name is composed by map name, Hashcode, tile width and height, tile format, T (transparent) and .smtiles suffix, such as China_69470548_256X256_PNG_T.smtiles and China_69470548_256X256_PNG.smtiles.

Description of MBTiles and SMTiles formats

MBTiles and SMTiles storage mechanism are basically the same. They manage the map tile data through "metadata", tiles, map datasheet, and image datasheet.

metadata (metadata table)

It adopts the key value to store the settings of map tile data, including "name" and "value" fields, in accordance with MBTiles 1.1 specification, as shown below:

The contents of the metadata table are as shown below:

Table 2 Example of metadata table

name

value

name World
type baselayer
version 1.1
ext_spec_version 201310
description World created on 2012-12-17 16:51:22 by SuperMap iServer
format PNG
bounds -180.0,-90.0,180.0,90.0
ext_spec_version 201309
axis_origin -180.0,90.0

axis_positive_direction

RightDown

crs_wkid

4326
crs_wkt

GEOGCS["WGS 84",

DATUM["WGS_1984",

SPHEROID["WGS 84", 6378137, 298.257223563, AUTHORITY["EPSG", "7030"]],

AUTHORITY["EPSG", "6326"]],

PRIMEM["Greenwich", 0, AUTHORITY["EPSG", "8901"]],

UNIT["degree", 0.0174532925199433, AUTHORITY["EPSG", "9122"]],

AUTHORITY["EPSG", "4326"]]

tile_height 256
tile_width 256
resolutions 78271.516964,529.1666666666670
scales 5.0E-7
transparent false
mapStatusHashCode

-411043745

map_parameter {"scale":0.00101610071425,"clipRegion":{"center":null,"id":0,"style...
compatible false

The keys of the metadata table are as shown below:

Table 3 Description of fields in metadata table

Field name Required Whether iserver extends Description
name Yes No Map English name. If the map name is Chinese, it will be changed to the Chinese Pinyin.
type Yes No Map type. The value is overlay or baselayer.
version Yes No The version of map tile data. MBTiles standard version is 1.1.
description Yes No Description.
format Yes No The format of tile data: png, jpg or jpg_png. The jpg_png is hybrid format supported by the V5cache.
bounds No No Map tile range. The unit and map unit should be remain the same. The bounds of iServer are: left, down, right, up, such as: -180,-85,180,85.
ext_spec_version No Yes The extended version of SuperMap iServer based on MBTiles standard. Here it is 201310.
axis_origin No Yes The position of the tile origin.
axis_positive_direction No Yes The enumerated type of positive direction in coordinate system (RightDown, RightUp, LeftDown, LeftUp). For example, x axis is right; y axis is RightDown.
crs_wkid No Yes The EPSG Code of coordinate system (-1000 is the custom coordinate system; 0 is the planar coordinate system).
crs_wkt No Yes Use wkt to represent the geographic coordinate system. (wkt: a kind of text-markup language made by OGC, please refer to http://docs.geotools.org/stable/javadocs/org/opengis/referencing/doc-files/WKT.html)
tile_height No Yes Tile width. It is usually 256.
tile_width No Yes Tile height. It is usually 256.
resolutions No Yes Resolution set. The resolution corresponding to tiles of all levels.
scales No Yes Scale set corresponding to resolution of all levels.
transparent No Yes whether the map image are transparent.
mapStatusHashCode No Yes The hash code of map name. For example, map World HashCode is: -411043745.
map_parameter No Yes The json string of map default parameter. Map default parameters contain all map characteristic, such as map name, mapScale and so on.
compatible No Yes Whether to be compatible with the MBTiles standards. When the wkid field is 3857, all resolutions in the set belong to MBTiles standard are true, otherwise, false.

tiles ( tile view)

Contain all tile data and values that used to locate.

MBTiles format supports four fields: zoom_level, tile_colum, tile_row and tile_data in MBTiles1.1 standard. Based on MBTiles, SMTiles adds resolution field to support scale and resolution. zoom_level are -1, as shown below.

Notes: when the ground resolution can not correspond to the resolution in table 3, zoom_level is -1.

Using the tiles view can reduce the redundant tiles. In sea or clear land, it may be several pieces with small scale, but in large scale, such as 1:10000, it may be millions of the single color blue tiles. Through splitting tile index and tile storage, MBTiles use view to relate the two. So the index of these tiles point to the same tile, which can reduce the redundancy of true color.

map (tile index table)

Include the values and tile id which are used to locate. Except the four fields in MBTiles1.1: zoom_level, tile_colum, tile_row and tile_id, it adds the resolution field. Support any scales or resolution. create_time field identifies the time of creating tile. If the tile is the pure color, tile_id is composed of the hexadecimal values of image RGB. For example, the red image tile_id is "ff0000". Others' tile_id is the cluster of resolution_x_y.

Figure 4 map structure chart

images (tile data table)

Include tile id and tile data.

 

According to resolution or corresponding scale, read tile data. For more information about MBTils scale and resolution, please refer to Table 1.