Survex 3d Format Specification

If you're writing in C or C++ it's strongly recommended that you use the img routine provided with Survex to read and write 3d files. Doing so means that you can take advantage of any revisions to the 3d format by simply rebuilding your software with the updated img routines, rather than having to update your own code. It also allows you to read a sub-set of the data in the file, restricted by Survey prefix.

This document only describes the more recent revisions of the 3d format (versions 3, 4, 5, and 6). Version 3 was produced by Survex versions 0.97 and later, version 4 by Survex 1.1.0-1.1.3, version 5 by Survex 1.1.4-1.1.10, and version 6 by versions from 1.1.11.

If you try to use this specification and find details which aren't spelled out clearly enough (or at all!) or any errors, please let us know. At least two people have successfully written code to read 3d files using this document, but that doesn't mean it can't be improved.

File Header

This consists of:

Items

Following the header are a number of items. The last item must be a 0x00 byte when the current label is empty, which marks the end of the data. The first byte of an item is a code identifying what the item is:

Code Type Data Meaning Version
0x00 STOP   If the current label is empty, signifies the end of the data in the 3d file; if the current label isn't empty, make it empty. ≥3
0x01 - 0x0e TRIM   Trim the last 16 characters of the current label, then trim back N (i.e. 1-14) dots ("."), everything after that particular dot. It's incorrect if the label ends up empty, or you attempt to trim more label than there is. The rationale for removing 16 characters first is that removal of 1-16 characters can be encoded by 0x10-0x1f (see below) and we can make this encoding more powerful by not overlapping what can be encoded. ≥3
0x0f MOVE <x> <y> <z> Set current position to the coordinates given. Coordinates are 4 byte little-endian signed integers representing values in centimetres (0.01 metres). ≥3
0x10 - 0x1f TRIM   Remove N-15 (i.e. 1-16) characters from the current label. It's incorrect if the label ends up empty, or you attempt to trim more label than there is. ≥3
0x20 DATE <date> Set survey date of legs (date is 4 byte little endian unsigned integer counting seconds since 1970) ≥4
0x21 DATE <date1><date2> Set survey date of legs to a range (date1, date2 are 4 byte little endian unsigned integer counting seconds since 1970) ≥4
0x22 ERROR <legs><length><E><H><V> Error information for the current traverse. <legs> is the number of legs. <length> is the total length of the traverse in cm (0.01m). E, H and V are the error and thehorizontal and vertical components in cm. (All values are 4 byte little endian signed integers) ≥6
0x23 - 0x2f     Reserved
0x30 - 0x31 XSECT <len> <label> <L> <R> <U> <D> Dimensions are 2 byte little-endian signed integers representing values in centimetres (0.01 metres). Omitted dimensions are encoded as 0xffff. Station flags are (N & 0x01): ≥5
Flag (N & 0x01) Meaning
0x01 Station is last one in this passage
0x32 - 0x33 XSECT <len> <label> <L> <R> <U> <D> Dimensions are 4 byte little-endian signed integers representing values in centimetres (0.01 metres). Omitted dimensions are encoded as 0xffffffff. ≥5
Flag (N & 0x01) Meaning
0x01 Station is last one in this passage
0x34 - 0x3f     Reserved
0x40 - 0x7f LABEL <len> <label> <x> <y> <z> Append label to the current label buffer. The updated contents of the label buffer give the survey stations full name. The length of label is given by length, which is encoded as follows: ≥3
Length Encoding
0 - 253 byte 0x00 - 0xfd
254-65789 byte 0xfe 2 byte little-endian unsigned integer len-254 0x0000-0xffff
65790 and greater byte 0xff 4 byte little-endian unsigned integer len 0x000100fd-0xffffffff
The station flags are encoded in the bottom 6 bits of the item code:
Flag (N & 0x3f) Meaning
0x01 Station is on leg above ground
0x02 Station is on an underground leg (both may be true at an entrance)
0x04 Station is marked as an entrance (with *entrance)
0x08 Station is exported (i.e. may be used as a connection point to other surveys)
0x10 Station is a fixed point (control point)
0x20 Reserved
0x80 - 0xbf LINE <len> <label> <x> <y> <z> Append label to the current label buffer. The length of the label is encoded as for a station label above. Return leg from current position to coordinates given, and update current position to coordinates given. The updated contents of the label buffer give the survey that the leg is in. ≥3
Flag (N & 0x3f) Meaning
0x01 Leg is above ground
0x02 Leg duplicates data in another leg (e.g. resurvey along a passage to tie into a known station)
0x04 Leg is a splay shot in a chamber (radial shots from a central point)
0x08 Reserved
0x10 Reserved
0x20 Reserved
0xc0 - 0xff     Reserved

Item order

Authors: Olly Betts and Mike McCombe, last updated: 2007-06-12