A note on tile names and directory structure
By jsharma-Oracle on Sep 02, 2013
This is a guest post by Honglei Zhu.
Important: The tiling scheme described here can, and likely will, change and hence be invalid in future releases.
This note outlines the tile storage, and file naming conventions, for map tile layers created with FMW MapViewer. The tiles are stored in a directory structure based on the data source name, map tile layer name, number of zoom levels, and tile mesh codes.
Tile Mesh Code and File Storage Structure
Each map tile layer is in a directory under $DEFAULT_TILE_STORAGE_ROOT and named [datasource.tile_layer_name]. For example, if the default tile storage is /private/tilestore and the tile layer demo_map is in the datasource is mvdemo, then the tiles will be under /private/tilestore/MVDEMO.DEMO_MAP. The first level of subdirectories contains one directory per zoom level. So if there are 19 zoom levels then the subdirectories will be named 0 through 18. Each zoom level directory will contain tile (files) or directories. That is, tiles are stored in a tree-like directory structure with leaf nodes contain only tile image files. Non-leaf nodes contain only directories. Mesh codes are used in naming these subdirectories and tiles.
Tile Mesh Code
A tile mesh code is represented by X (horizontal) and Y (vertical) integer arrays, in a form of [meshX0, meshX1, meshX2, … meshXn] and [meshY0, meshY1, meshY2, … meshYn]. At each zoom level, the length for the X and Y mesh code array is always the same. Different zoom levels, however, may have different length arrays. The longer the mesh code, the more tile images that zoom level contains.
For a tile with mesh code of [meshX0, meshX1, meshX2, … meshXn] and [meshY0, meshY1, meshY2, … meshYn], its filename and path is: $DEFAULT_TILE_STORAGE_ROOT/[tile_layer_name]/[zoom_level]/[meshX0]_[meshY0]/ [meshX1]_[meshY1]/ [meshX2]_[meshY2]/…/ [meshXn]_[meshYn].png.
For example, a MVDEMO.DEMO_MAP tile at zoom level 10, with an X mesh code of [1, 12, 11] and a Y mesh code of [3, 12, 9] will be at: /private/tilestore/MVDEMO.DEMO_MAP/10/1_3/12_12/11_9.png
Note:Tile mesh codes are internal to MapViewer and are may change between releases. So the following description of how mesh codes are generated may not be valid in future releases.
The mesh code is computed from a tile index. The tile index (X,Y) is computed in the Oracle maps client code from the map tile layer definition as follows:
tileIndexX = (tileMinX–CoordinateSystem.minX) / tileWidth;
tileIndexY = (tileMinY–CoordinateSystem.minY) / tileHeight;
The server then converts the tile index to a mesh code.
Directory Tree Depth (Mesh Code Length)
When the number of tile images is small for a given zoom level, all tiles may be stored in its root directory. When the number gets to millions or even larger, at higher zoom levels, they are stored in subdirectories for more efficient file retrieval.
The expected number of tiles for a given zoom level is calculated using:
maxMeshCodeX = coordinateSystem.width/tileWidth;
maxMeshCodeY = coordinateSystem.height/tileHeight;
total_tiles = maxMeshCodeX*maxMeshCodeY;
A TILING_FACTOR determines the depth of the directory tree for a given zoom level. The default value of 20 means there will be no more than 400 (20 x 20) sub-directories or tile images stored at any zoom level. The mesh code length for X equals the base-20 (or base TILING_FACTOR) logarithm of maxMeshCodeX.
Examples of converting a tile index (x,y) to Mesh Code
1) Given that the TILING_FACTOR is 20, then for zoom level 6, the mesh code length is 4. If the tile index (x,y)=(6063, 7403), then its mesh code is x=[0,15,3,3], y=[0,18,10,3], and the tile is stored at:[tile_layer_name]\6\0_0\15_18\3_10\3_3.png
2) If the TILING_FACTOR is changed to 10, the mesh code length becomes 5. Keeping the zoom level and tile index the same, the mesh code is x=[0, 6, 0, 6, 3], y=[0,7,4,0,3], and the tile is stored at: [tile_layer_name]\6\0_0\6_7\0_4\6_0\3_3.png