HAFAS-Palm PDB Timetable File Format ==================================== Document version: 0.8 Copyright (c) 2006 Arkadiusz [Yak] Wahlig This document describes the file format of the precalculated timetable file used by HAFAS-Palm application for Palm OS. http://www.hacon.de/hafas_e/palm.shtml Such files can easily be calculated using folmular on this site: http://persoenlicherfahrplan.bahn.de No code was disassembled to gain this information. Every piece of information was observed using a HEX viewer only. General: ======== All integer numbers are stored in Big-Endian. Abbreviations: ============== This document uses following abbreviations: STR: Value is an offset into Strings table record DATE: Value is a number of days after 31.12.1979 TIME: Value is time stored as decimal value, for example 4:33 is stored as 433 (0x1b1); 0xFFFF means the time is unset/unknown PTIME: PDB-Time, value is number of seconds since since 00:00 on January 1, 1904 Header: ======= The file starts with a standard Palm OS PDB file header as described here: http://www.palmos.com/dev/support/docs/fileformats/Intro.html#970318 Offset Length Description ----------------------------------------------------------------------- 0x0000 0x0020 Name (Ascii, ex. "86q1e-pjndd-X06-Hafa") 0x0020 0x0002 Attributes (0x0008) 0x0022 0x0002 Version (0x0000) 0x0024 0x0004 PTIME: Creation time 0x0028 0x0004 PTIME: Modification time 0x002c 0x0004 PTIME: Last backup time 0x0030 0x0004 Modification number 0x0034 0x0004 AppInfo offset (0x00000000, no AppInfo) 0x0038 0x0004 SortInfo offset (0x00000000, no SortInfo) 0x003c 0x0004 Type ("plan") 0x0040 0x0004 Creator ("Hafa") 0x0044 0x0004 Unique ID seed (0x00000000) 0x0048 ...... Record list Record list: ============ 0x0000 0x0004 Next record list offset (unused, 0x00000000) 0x0004 0x0002 Number of records 0x0006 ...... Records Record: ======= 0x0000 0x0004 Offset from the start of file to record data 0x0004 0x0001 Attributes (0x00) 0x0005 0x0003 Unique ID (0x000000) Hafas database records function: ================================ The Record list described above provides offsets to the records. Their function in the Hafas timetable file is following: Record Function Notes ----------------------------------------------------------------------- 0 Timetable Main Timetable information structure 1 Strings 2 Remarks 3 Availability 4 Connection One of many (possibly) connection records ... n Connection Number of Connections is set in Timetable n+1 ? (1 byte = 00) n+2 ? (1 byte = 00) n+3 ? (1 byte = 00) n+4 ? (1 byte = 00) n+5 ? The processing of the file should start with the Timetable record. From there you can get offsets into Strings record and most importantly, the number of connections. Then you can proceed to the Connection records which in turn will provide you with offsets into Strings, Remarks and Availability records. The function of five last records is unknown. Timetable: ========== 0x0000 0x0002 Version (0x0003) 0x0002 0x0032 From (Ascii) 0x0034 0x0032 To (Ascii) 0x0066 0x0002 Number of connections 0x0068 0x0002 DATE: Period start date, also base date for availability data 0x006a 0x0002 DATE: Period end date 0x006c 0x0002 ? (0x0001) 0x006e 0x0002 ? (0x0000) 0x0070 0x0002 DATE: Creation date 0x0072 0x0006 Timetable ID (Ascii), null-padded 0x0078 0x0002 STR: Availability period 0x007a 0x0002 STR: Some code (?) 0x007c ...... Stops table The number of Stops isn't noted anywhere since they are pointed directly to from other records (using offsets from the start of this record). Stop (size = 0x0a): ------------------- 0x0000 0x0002 STR: Name 0x0002 0x0002 ? 0x0004 0x0002 ? 0x0006 0x0002 ? 0x0008 0x0002 ? Strings: ======== Concatenated Ascii strings separated by '\0' character. The number of those isn't noted anywhere since they are pointed directly to from other records (using offsets from the start of this record). Remarks: ======== One or more following nodes. The number of those isn't noted anywhere since they are pointed directly to from other records (using offsets from the start of this record). Remark (size = 0x0a): --------------------- 0x0000 0x0002 STR: Remark text 0x0002 0x0002 Type (1=direction, 3=walk time, ...) 0x0004 0x0006 ? (0xFFFFFFFFFFFF) Availability: ============= One or more following nodes. The number of those isn't noted anywhere since they are pointed directly to from other records (using offsets from the start of this record). Availability: ------------- 0x0000 0x0002 STR: Connection availability description 0x0002 0x0002 Number of 8-days chunks after base date (see Timetable) 0x0004 0x0002 Size of availability data in bytes 0x0006 0x0002 Availability data. Each bit represents one day. Connection is available in this day if bit equals 1. Connection: =========== 0x0000 0x0002 Offset into the Availability table 0x0002 0x0002 Number of transitions 0x0004 0x0002 TIME: Duration 0x0006 0x0002 Number of means of transportation 0x0008 0x0002 Offset from start of this Connection to Passes table 0x000a ...... Means table Mean (size = 0x2e): ------------------- 0x0000 0x0002 Type (1=walk, 2=ride, ...) 0x0002 0x0002 STR: From 0x0004 0x000a Additional 'from' info (Ascii) 0x000e 0x0002 TIME: Departure time 0x0010 0x0002 STR: To 0x0012 0x000a Additional 'to' info (Ascii) 0x001c 0x0002 TIME: Arrival time 0x001e 0x000a Mean name (Ascii) 0x0028 0x0002 Offset into the Remarks record 0x002a 0x0002 Index into the Passes table 0x002c 0x0002 Number of Passes Pass (size = 0x10): ------------------- 0x0000 0x0002 Index into the Stops table 0x0002 0x000a Additional info (Ascii) 0x000c 0x0002 TIME: Arrival time 0x000e 0x0002 TIME: Departure time