User:MPC/TRE Subfile Format

From OpenStreetMap Wiki
Jump to: navigation, search

User:MPC

The beginning of the .TRE file typically looks like that:

0001C600   BC 00 47 41 52 4D 49 4E 20 54 52 45 01 00 D9 07   ..GARMIN TRE....
0001C610   0B 08 14 14 25 00 C0 25 00 D8 7F 00 80 24 00 98   ....%..%.....$..
0001C620   7A 98 01 00 00 18 00 00 00 B0 01 00 00 9C 02 00   z...............
0001C630   00 4C 04 00 00 09 00 00 00 03 00 00 00 00 00 00   .L..............
0001C640   19 00 00 01 03 11 00 01 00 00 58 04 00 00 0E 00   ..........X.....
0001C650   00 00 02 00 00 00 00 00 66 04 00 00 04 00 00 00   ........f.......
0001C660   02 00 00 00 00 00 55 04 00 00 03 00 00 00 03 00   ......U.........
0001C670   00 00 00 00 10 27 00 00 00 00 00 00 58 04 00 00   .....'......X... (0x74: Map ID plaintext)
0001C680   00 00 00 00 0D 00 07 06 00 00 58 04 00 00 00 00   ..........X.....
0001C690   00 00 04 00 00 00 00 00 00 00 CE 2B DC E3 CD 2B   ...........+...+ (0x9a: Map ID hash)
0001C6A0   78 CC CD 2B CC CC CD 2B CC CC 00 00 00 00 00 00   x..+...+........
0001C6B0   00 00 00 00 00 00 00 00 00 00 00 00 4F 53 4D 20   ............OSM
0001C6C0   53 74 72 65 65 74 20 6D 61 70 00 68 74 74 70 3A   Street map.http:
0001C6D0   2F 2F 77 77 77 2E 6F 70 65 6E 73 74 72 65 65 74   //www.openstreet
0001C6E0   6D 61 70 2E 6F 72 67 2F 00 4D 61 70 20 64 61 74   map.org/.Map dat
Map ID
The map ID is saved in Lower Endian and has a length of 4 bytes.
The map ID needs to be unique if you want to join multiple maps to one gmapsupp.img!
Example: A map ID of 11259375 is 0x00abcdef (hexadecimal) which results in 0xefcdab00.
Map ID hash
The map ID hash starts at offset 0x9a and has a length of 16 bytes. It absolutely has to match the Map ID, otherwise the map most likely won’t show up on Garmin devices.
See MapValues.java from mkgmap about how to calculate the hash.

Header

TRE Header

Common Header

The structure of the common header is the same in all subfiles.

Byte Offset Length (bytes) Description
0x000 2 Header length.
0x002 10 Type GARMIN TRE
0x00C 1 0x01 ?
0x00D 1 0x00
0x00E 2 Creation year
0x010 1 Creation month
0x011 1 Creation day
0x012 1 Creation hour
0x013 1 Creation minute
0x014 1 Creation second

Specific TRE Header

Byte Offset Length (bytes) Description
0x015 3 North boundary
0x019 3 East boundary
0x01B 3 South boundary
0x01E 3 West boundary
0x021 4 Offset of map levels section, TRE1
0x025 4 Size of map levels section, TRE1
0x029 4 Offset of map subdivisions section, TRE2
0x02D 4 Size of map subdivisions section, TRE2
0x031 4 Offset of map copyrights section, TRE3
0x035 4 Size of map copyrights section, TRE1
0x039 2 Copyright record size
0x03B 4 0x00000000, unknown
0x03F 1 Flags: 0: detailed map, 1: transparent map, 2: show street before street number, 3: show zip before city, 4-7: ??
0x040 3 display priority
0x043 1 0x11; distance for start route recalculation
0x044 1 0x03; draw priority (overrules DP if set inside tdb)
0x045 1 unknown; 0x01 spotted
0x046 1 unknown; 0x00 spotted
0x047 3 0x000100 unknown

For more information on TRE7 and TRE8 see exploring img