OSM Map On Magellan/Format/raimadb

From OpenStreetMap Wiki
Jump to navigation Jump to search

Raima DB

The Magellan Map file uses a Raima DB Version 3.0 for storing text informations. This tries not to be a complete specification on the data base binary format. It shall only list, what is needed to know about it, to generate a compatible map.

The Raima Db conatains several tables, each stored within a single file and a dictionary file (db00.dbd) When the database is used in compression mode, there also exists one file per table, containing compression data/indexes.


db00.dbd

The dictionary lists all files, tables and fields belonging to the db. The file starts with a 22 bytes header, followed by the file table, then the list of tables and at least all fields within the tables.

Header
Bytes 0 - 21 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
0x56 (byte) 0x33 (byte) 0x2E (byte) 0x30 (byte) 0x30 (byte) 0x1A (byte) PageSize (short) Number of Files (short) Number of Tables (short) Number of Fields (short) 0x00 (byte) 0x00 (byte) 0x00 (byte) 0x00 (byte) 0x00 (byte) 0x00 (byte) 0x00 (byte) 0x00 (byte)

The PageSize is used in the table files. The data in the tables is organized in pages. This values specifies how big they are.


File Descriptor

Each file belonging to the database is described in the list of file descriptor. Each file descriptor is 60 bytes long. The first 49 bytes are reserved for the file name, the rest contains some flags and parameters belonging to the file.

File Descriptor
Bytes 22 - 81 0 - 48 49 50 51 52 53 54 55 56 57 58 59
File Name (ASCII) 0x00 (byte) 0x63=Closed (short) 0x64=Data (short) Aligned Record Length (short) 0x200 Page Size (short) 0x40=Compressed (short)

Each record inside a table must start on an even byte position. When the record length is odd the aligned record length is the real record length plus 1.

Here is the file descriptor for a compression table:

Compression Data File Descriptor
Bytes 82 - 141 0 - 48 49 50 51 52 53 54 55 56 57 58 59
File Name (ASCII) 0x00 (byte) 0x63=Closed (short) 0x63=Compression Data (short) Aligned Record Length (short) 0x200 Page Size (short) 0x40=Compressed (short)

Compression data Files have the file name extension as the corresponding file and also the name is nearly the same. The difference is a trailing c in the name of the compression data file.

Data File 00cn.dat => Compression data File 00cnc.dat

Table Descriptor

Next follows the list of tables. Each Entry in this list is 12 bytes long. The compression tables are not listed here only the tables containing data.


Table Descriptor
Bytes 142 - 153 0 1 2 3 4 5 6 7 8 9 10 11
Index of Table File in File List (short) Record Length (short) 0x06 (short) Index of first Field in Field List (short) Number of Fields (short) 0x00 (short)

List of Fields

Each table may have multiple fields per row. All fields of all tables are listed next. In the table descriptor there is an index (Index of first Field in Field list) pointing to the first field belonging to a table. Following types of fields are used within magellan data base files:

byte
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
0x63 (byte) 0x01 Field length (short) 0x00 Dimension (short) 0x00 (short) 0x00 (short) 0x00 (short) 0x00 (short) Field offset within table row (short) Number of Table (short) 0x04 (short) 0x00 (byte)
short
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
0x73 (byte) 0x02 Field length (short) 0x00 Dimension (short) 0x00 (short) 0x00 (short) 0x00 (short) 0x00 (short) Field offset within table row (short) Number of Table (short) 0x04 (short) 0x00 (byte)
integer
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
0x6C (byte) 0x04 Field length (short) 0x00 Dimension (short) 0x00 (short) 0x00 (short) 0x00 (short) 0x00 (short) Field offset within table row (short) Number of Table (short) 0x04 (short) 0x00 (byte)
String (length = 248)
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
0x63 (byte) 0xF8 Field length (short) 0xF8 Dimension (short) 0x01 (short) 0x00 (short) 0x00 (short) 0x00 (short) Field offset within table row (short) Number of Table (short) 0x00 (short) 0x00 (byte)
Array of Integer (Dim = 39)
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
0x6C (byte) 0x9C Field length (short) 0x27 Dimension (short) 0x00 (short) 0x00 (short) 0x00 (short) 0x00 (short) Field offset within table row (short) Number of Table (short) 0x04 (short) 0x00 (byte)
String (Length = 25)
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
0x63 (byte) 0x19 Field length (short) 0x19 Dimension (short) 0x00 (short) 0x00 (short) 0x00 (short) 0x00 (short) Field offset within table row (short) Number of Table (short) 0x00 (short) 0x00 (byte)


The file ends with the list of table names and field names, each seperated by a Carriage return ('\n').


Each row in a table has 6 starting bytes containing table and row number.

Row prefix
0 1 2 3 4 5
Table Number (short) TableNumber << 25 + row (int)

Tables

The first table in the Database is a zip Code table and a City name table. These two tables are typically empty.

Zip Code Table (table name = "Z_R", file name = "00z.dat")
"ZIP_CODE" (integer) "C_REF" (integer)
City names (table name = "C_R", file name = "00cn.dat")
"CITY_BUF" (String[248])


This is followed by three tables per group containing names of elements in the layer files and linkage informations. ([GroupNr.] is a placeholder for the numerical number of the group, the three tables belong to.

Text table (table name = "AUX_GR[GroupNr.]", file name = "00gc[GroupNr.].aux")
"NAME_BUF" (String[248])

This table can contain several texts/names in a single row. When this is the case, all texts are seperated by a 0x00 byte. It is also possible, that a text exceeds a single line. In this case the last byte of the String is not a 0x00 but any character. This is used to tell the interpreter, that the text is continued in the next row. In all other cases the last byte in the array must always be a 0x00.

Link table (table name = "R_GR[GroupNr.]", file name = "00gc[GroupNr.].ext")
"NAME_REF" (integer) "CELL_NUM" (integer) "N_IN_C" (integer) "OBJ_TYPE" (short)

This table links between the elements in layer files.

  • 'NAME_REF' references a text entry in the Text Table. It is calculated by NAME_REF = (Offset of the text in the row) << 24 + (row number)
  • 'CELL_NUM' is the number of the cell in the layer file.
  • 'N_IN_C' is the number of the referenced element within the cell
  • 'OBJ_TYPE' is at the end nothing else than the layer itself.

(All types listed in the table description are field types from the chapter before)

CLP table (table name = "RC_GR[GroupNr.]", file name = "00gc[GroupNr.].clp")
"CELL_NUM" (integer) "N_IN_C" (integer)

This table can remain empty. (Purpose is unclear)

Example

Here is an example of an db00.dbd file for a table with a single group. All files in the table are compressed. Following files are belonging to the database:

  • 00cn.dat City Name References
  • 00cnc.dat Compression data for 00cn.dat
  • 00z.dat Zip code table
  • 00zc.dat Corresponding Compression data
  • 00gr0.aux Text Table
  • 00gr0c.aux Compression data
  • 00gr0.ext Link table
  • 00gr0c.ext Compression data
  • 00gr0.clp CLP Table
  • 00gr0c.clp Compression data
  • db00.dbd Database dictionary


0x56 0x33 0x2E 0x30 0x30 0x1A 0x00 0x02 0x0A 0x00 0x05 0x00 0x0A 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x30 0x30 0x7A 0x2E 0x64 0x61 0x74 0x00 0x00 0x00 0x00 0x00 0x00 0x00
0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
0x63 0x64 0x24 0x00 0x0E 0x00 0x00 0x02 0x40 0x00 0x30 0x30 0x7A 0x63 0x2E 0x64 0x61 0x74 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x63 0x63 0x3F 0x00 0x08 0x00 0x00 0x02 0x00 0x00 0x30 0x30
0x63 0x6E 0x2E 0x64 0x61 0x74 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x63 0x64 0x02 0x00 0xFE 0x00 0x00 0x02 0x40 0x00 0x30 0x30 0x63 0x6E 0x63 0x2E 0x64 0x61 0x74 0x00 0x00 0x00 0x00 0x00
0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
0x63 0x63 0x3F 0x00 0x08 0x00 0x00 0x02 0x00 0x00 0x30 0x30 0x67 0x72 0x30 0x2E 0x65 0x78 0x74 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x63 0x64 0x1C 0x00 0x12 0x00 0x00 0x02 0x40 0x00 0x30 0x30
0x67 0x72 0x30 0x63 0x2E 0x65 0x78 0x74 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x63 0x63 0x3F 0x00 0x08 0x00 0x00 0x02 0x00 0x00 0x30 0x30 0x67 0x72 0x30 0x2E 0x63 0x6C 0x70 0x00 0x00 0x00 0x00 0x00
0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
0x63 0x64 0x2A 0x00 0x0C 0x00 0x00 0x02 0x40 0x00 0x30 0x30 0x67 0x72 0x30 0x63 0x2E 0x63 0x6C 0x70 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x63 0x63 0x3F 0x00 0x08 0x00 0x00 0x02 0x00 0x00 0x30 0x30
0x67 0x72 0x30 0x2E 0x61 0x75 0x78 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x63 0x64 0x02 0x00 0xFE 0x00 0x00 0x02 0x40 0x00 0x30 0x30 0x67 0x72 0x30 0x63 0x2E 0x61 0x75 0x78 0x00 0x00 0x00 0x00
0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
0x63 0x63 0x3F 0x00 0x08 0x00 0x00 0x02 0x00 0x00 0x00 0x00 0x0E 0x00 0x06 0x00 0x00 0x00 0x02 0x00 0x00 0x00 0x02 0x00 0xFE 0x00 0x06 0x00 0x02 0x00 0x01 0x00 0x00 0x00 0x04 0x00
0x11 0x00 0x06 0x00 0x03 0x00 0x04 0x00 0x00 0x00 0x06 0x00 0x0C 0x00 0x06 0x00 0x07 0x00 0x02 0x00 0x00 0x00 0x08 0x00 0xFE 0x00 0x06 0x00 0x09 0x00 0x01 0x00 0x00 0x00 0x6E 0x6C
0x04 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x06 0x00 0x00 0x00 0x04 0x00 0x6E 0x6C 0x04 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x0A 0x00 0x00 0x00
0x04 0x00 0x6E 0x63 0xF8 0x00 0xF8 0x00 0x01 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x06 0x00 0x01 0x00 0x00 0x00 0x6E 0x6C 0x04 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
0x06 0x00 0x02 0x00 0x04 0x00 0x6E 0x6C 0x04 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x0A 0x00 0x02 0x00 0x04 0x00 0x6E 0x73 0x02 0x00 0x00 0x00 0x00 0x00 0x00 0x00
0x00 0x00 0x00 0x00 0x0E 0x00 0x02 0x00 0x04 0x00 0x6E 0x63 0x01 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x10 0x00 0x02 0x00 0x04 0x00 0x6E 0x6C 0x04 0x00 0x00 0x00
0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x06 0x00 0x03 0x00 0x04 0x00 0x6E 0x73 0x02 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x0A 0x00 0x03 0x00 0x04 0x00 0x6E 0x63
0xF8 0x00 0xF8 0x00 0x01 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x06 0x00 0x04 0x00 0x00 0x00 0x5A 0x5F 0x52 0x0A 0x43 0x5F 0x52 0x0A 0x52 0x5F 0x47 0x52 0x30 0x0A 0x52 0x43 0x5F 0x47
0x52 0x30 0x0A 0x41 0x55 0x58 0x5F 0x47 0x52 0x30 0x0A 0x5A 0x49 0x50 0x5F 0x43 0x4F 0x44 0x45 0x0A 0x43 0x5F 0x52 0x45 0x46 0x0A 0x43 0x49 0x54 0x59 0x5F 0x42 0x55 0x46 0x0A 0x4E
0x41 0x4D 0x45 0x5F 0x52 0x45 0x46 0x0A 0x43 0x45 0x4C 0x4C 0x5F 0x4E 0x55 0x4D 0x0A 0x4E 0x5F 0x49 0x4E 0x5F 0x43 0x0A 0x4F 0x42 0x4A 0x5F 0x54 0x59 0x50 0x45 0x0A 0x43 0x45 0x4C
0x4C 0x5F 0x4E 0x55 0x4D 0x0A 0x4E 0x5F 0x49 0x4E 0x5F 0x43 0x0A 0x4E 0x41 0x4D 0x45 0x5F 0x42 0x55 0x46 0x0A