Osb spec v2

From OpenStreetMap Wiki
Jump to navigation Jump to search

Primitives

id Type Size (bytes) Description
<PTR> int64 8 Offset inside the file
<STRING> int32 + n * int16 4 + n * 2 A string. length in bytes + n*Wchar, UTF16 encoded

Structure

Elements

Header

Type Size (bytes) Description Remarks
char(3) 3 'O', 'S', 'B' Magic
int16 2 2 Version
<PTR> 8 [RegionToc] Offset to file Region Table-of-content
<PTR> 8 [TagKeys] Offset to Tag keys table
<PTR> 8 [TagValues] Offset to Tag values table

Tags

TagKeys

Type Size (bytes) Description Remarks
int32 8 [numKeys] Number of unique keys
String (String)*[numKeys] Keys List of Keys

TagValues

Type Size (bytes) Description Remarks
int32 8 [numValues] Number of unique values
<STRING> <STRING>*[numValues] Values List of Values

Features

Nodes

Type Size (bytes) Description Remarks
char 1 'N' Magic
int64 8 id OSM id
int32 4 longitude
int32 4 latitude

Ways

Type Size (bytes) Description Remarks
char 1 'R' Magic
int64 8 id OSM id
int32 4 (numNodes) number of nodes
<PTR> 8*(numNodes) list of node offset

Relations

Header

Type Size (bytes) Description Remarks
char 1 'L' Magic
int64 8 id OSM id
int32 4 (numChildren) number of children
Children

Type Size (bytes) Description Remarks
char 1 'N' or 'R' or 'L' Child type
<PTR> 8 [Child] Offset to child definition
String (String) Role Child role

TileTOC

Header

Type Size (bytes) Description Remarks
int32 4 [numFeatures] number of features in the tile

Item

Type Size (bytes) Description Remarks
<PTR> 8 Feature offset Offset to one feature in the tile

TileRegionTOC

Header

Type Size (bytes) Description Remarks
int32 4 [numTiles] number of tiles in the region

Item

Type Size (bytes) Description Remarks
int32 4 [idTile] the ID of the Tile
<PTR> 8 Tiles offset Offset to the list of features for the tile

RegionToc

Header

Type Size (bytes) Description Remarks
int32 4 [numRegions] number of regions in the TOC

Item

Type Size (bytes) Description Remarks
int32 4 [idRegion] the ID of the Region
<PTR> 8 Tiles offset Offset to the list of tiles for the region