| 1 | <!DOCTYPE HTML PUBLIC "-//W4C//DTD HTML 4.0 Transitional//EN"> |
|---|
| 2 | <HTML><HEAD> |
|---|
| 3 | <TITLE>Survex 3d Format Specification</TITLE> |
|---|
| 4 | <STYLE type="text/css"><!-- |
|---|
| 5 | BODY, TD, TH, CENTER, UL, OL {font-family: sans-serif;} |
|---|
| 6 | TD, TH {font-size: 11pt; vertical-align: top;} |
|---|
| 7 | TH {white-space: nowrap; background-color: #ffc;} |
|---|
| 8 | .code {text-align: center; white-space: nowrap;} |
|---|
| 9 | .type {text-align: center; white-space: nowrap;} |
|---|
| 10 | .data {text-align: left; white-space: nowrap;} |
|---|
| 11 | .desc {text-align: left; white-space: wrap;} |
|---|
| 12 | .version {text-align: center; white-space: wrap;} |
|---|
| 13 | TH.data, TH.desc {text-align: center;} |
|---|
| 14 | .reserved {background-color: #ddd;} |
|---|
| 15 | --> |
|---|
| 16 | </STYLE> |
|---|
| 17 | </HEAD><BODY BGCOLOR=white TEXT=black> |
|---|
| 18 | <H1>Survex 3d Format Specification</H1> |
|---|
| 19 | |
|---|
| 20 | <P>If you're writing in C or C++ it's <b>strongly</b> recommended |
|---|
| 21 | that you use the img routine provided with Survex to read and write |
|---|
| 22 | 3d files. Doing so means that you can take advantage of any revisions |
|---|
| 23 | to the 3d format by simply rebuilding your software with the updated |
|---|
| 24 | img routines, rather than having to update your own code. It also |
|---|
| 25 | allows you to read other processed survey data formats (those from |
|---|
| 26 | Larry Fish's Compass and from Bob Thrun's CMAP), and allows reading |
|---|
| 27 | a sub-set of the data in a file, restricted by survey prefix.</P> |
|---|
| 28 | |
|---|
| 29 | <P>This document only describes the most recent revision of the 3d format |
|---|
| 30 | (version 8) which is produced by versions from 1.2.7. A <a |
|---|
| 31 | href="3dformat-old.htm">separate document</a> describes older versions. |
|---|
| 32 | </P> |
|---|
| 33 | |
|---|
| 34 | <P>If you try to use this specification and find details which aren't |
|---|
| 35 | spelled out clearly enough (or at all!) or any errors, please let us know. |
|---|
| 36 | At least two people have successfully written code to read 3d files |
|---|
| 37 | using this document, but that doesn't mean it can't be improved. |
|---|
| 38 | </P> |
|---|
| 39 | |
|---|
| 40 | <H2>File Header</H2> |
|---|
| 41 | |
|---|
| 42 | <P>This consists of:</P> |
|---|
| 43 | |
|---|
| 44 | <ul> |
|---|
| 45 | <li> File ID: the string "Survex 3D Image File" followed by a linefeed |
|---|
| 46 | (decimal 10, hex 0a). [Note: v0.01 files can have a carriage return |
|---|
| 47 | before this and other linefeeds - this is a file format error in any |
|---|
| 48 | other format version]. |
|---|
| 49 | <li> File format version: "v8" followed by a linefeed. |
|---|
| 50 | Any future versions will be "v9", "v10", "v11", etc. |
|---|
| 51 | <li> Assorted string metadata - the sublist below lists these, and they |
|---|
| 52 | must appear in the order given, separated by zero bytes, with the end of |
|---|
| 53 | the metadata marked by a linefeed. More items may be added, so ignore any |
|---|
| 54 | additional ones which are present. Any trailing items with empty values |
|---|
| 55 | can be omitted along with the separating zero byte before them. |
|---|
| 56 | <ul> |
|---|
| 57 | <li>Survey title: Human readable description of the data in the file. |
|---|
| 58 | There's no length limit on this string. |
|---|
| 59 | <li>Coordinate system: string describing the coordinate system in use |
|---|
| 60 | which can be passed to PROJ. For a coordinate system with an EPSG code |
|---|
| 61 | <code>EPSG:</code> followed by the code number can be used (we recommend |
|---|
| 62 | using this if an EPSG code exists). Similarly, an ESRI code can be specified |
|---|
| 63 | with <code>ESRI:</code> followed by the code number. |
|---|
| 64 | <li>Survey hierarchy separator character. Survey station names form a |
|---|
| 65 | hierarchy, and this character separates levels in the hierarchy. E.g. |
|---|
| 66 | <code>161.entrance.6</code>. Defaults to <code>.</code> if this item is not |
|---|
| 67 | specified, which is also the recommended character to use unless <code>.</code> |
|---|
| 68 | is used in survey or station names (especially as older software will not see |
|---|
| 69 | this metadata and will use <code>.</code> unconditionally). |
|---|
| 70 | </ul> |
|---|
| 71 | <li> Timestamp: A string consisting of an '@' followed by a count of |
|---|
| 72 | seconds since the start of 1970 in UTC ("Unix time_t") as a string |
|---|
| 73 | (for example: "@1371300355"), followed by a linefeed. This is intended to be |
|---|
| 74 | the time the file was generated, rather than the time the survey data was |
|---|
| 75 | collected. |
|---|
| 76 | <li> File-wide flags: a single byte. If bit 7 is set, this is an extended |
|---|
| 77 | elevation. All other bits are reserved - set them to 0 when writing, and |
|---|
| 78 | ignore them when reading. |
|---|
| 79 | </ul> |
|---|
| 80 | |
|---|
| 81 | <H2>Items</H2> |
|---|
| 82 | |
|---|
| 83 | <P>Following the header are a number of items. The last item must be a 0x00 |
|---|
| 84 | byte when the current label is empty, which marks the end of the data. The |
|---|
| 85 | first byte of an item is a code identifying what the item is:</P> |
|---|
| 86 | |
|---|
| 87 | <table border="1" cellpadding="1" cellspacing="0" width="100%"> |
|---|
| 88 | <tr> |
|---|
| 89 | <th class="code">Code</th> |
|---|
| 90 | <th class="code">Type</th> |
|---|
| 91 | <th class="data">Data</th> |
|---|
| 92 | <th class="desc" colspan="2">Meaning</th> |
|---|
| 93 | <th class="version">Version</th> |
|---|
| 94 | </tr> |
|---|
| 95 | <tr> |
|---|
| 96 | <td class="code">0x00</td> |
|---|
| 97 | <td class="type">STYLE_NORMAL / STOP</td> |
|---|
| 98 | <td class="data"> </td> |
|---|
| 99 | <td colspan="2"> |
|---|
| 100 | Set style for following legs to tape, compass and clino. |
|---|
| 101 | <p> |
|---|
| 102 | If the style is already set to STYLE_NORMAL, this code signifies the |
|---|
| 103 | end of the data in the 3d file.</td> |
|---|
| 104 | <td class="version">≥8</td> |
|---|
| 105 | </tr> |
|---|
| 106 | <tr> |
|---|
| 107 | <td class="code">0x01</td> |
|---|
| 108 | <td class="type">STYLE_DIVING</td> |
|---|
| 109 | <td class="data"> </td> |
|---|
| 110 | <td colspan="2"> |
|---|
| 111 | Set style for following legs to diving data</td> |
|---|
| 112 | <td class="version">≥8</td> |
|---|
| 113 | </tr> |
|---|
| 114 | <tr> |
|---|
| 115 | <td class="code">0x02</td> |
|---|
| 116 | <td class="type">STYLE_CARTESIAN</td> |
|---|
| 117 | <td class="data"> </td> |
|---|
| 118 | <td colspan="2"> |
|---|
| 119 | Set style for following legs to cartesian data</td> |
|---|
| 120 | <td class="version">≥8</td> |
|---|
| 121 | </tr> |
|---|
| 122 | <tr> |
|---|
| 123 | <td class="code">0x03</td> |
|---|
| 124 | <td class="type">STYLE_CYLPOLAR</td> |
|---|
| 125 | <td class="data"> </td> |
|---|
| 126 | <td colspan="2"> |
|---|
| 127 | Set style for following legs to cylindrical polar data</td> |
|---|
| 128 | <td class="version">≥8</td> |
|---|
| 129 | </tr> |
|---|
| 130 | <tr> |
|---|
| 131 | <td class="code">0x04</td> |
|---|
| 132 | <td class="type">STYLE_NOSURVEY</td> |
|---|
| 133 | <td class="data"> </td> |
|---|
| 134 | <td colspan="2"> |
|---|
| 135 | Set style for following legs to unsurveyed</td> |
|---|
| 136 | <td class="version">≥8</td> |
|---|
| 137 | </tr> |
|---|
| 138 | <tr class="reserved"> |
|---|
| 139 | <td class="code">0x05 - 0x0e</td> |
|---|
| 140 | <td class="type"> </td> |
|---|
| 141 | <td class="data"> </td> |
|---|
| 142 | <td class="desc" colspan="3">Reserved</td> |
|---|
| 143 | </tr> |
|---|
| 144 | <tr> |
|---|
| 145 | <td class="code">0x0f</td> |
|---|
| 146 | <td class="type">MOVE</td> |
|---|
| 147 | <td class="data"><x> <y> <z></td> |
|---|
| 148 | <td class="desc" colspan="2"> |
|---|
| 149 | Set current position to the coordinates given. Coordinates |
|---|
| 150 | are 4 byte little-endian signed integers representing |
|---|
| 151 | values in centimetres (0.01 metres).</td> |
|---|
| 152 | <td class="version">≥8</td> |
|---|
| 153 | </tr> |
|---|
| 154 | <tr> |
|---|
| 155 | <td class="code">0x10</td> |
|---|
| 156 | <td class="type">DATE</td> |
|---|
| 157 | <td class="data"> </td> |
|---|
| 158 | <td colspan="2"> |
|---|
| 159 | No survey date information was specified.</td> |
|---|
| 160 | <td class="version">≥8</td> |
|---|
| 161 | </tr> |
|---|
| 162 | <tr> |
|---|
| 163 | <td class="code">0x11</td> |
|---|
| 164 | <td class="type">DATE</td> |
|---|
| 165 | <td class="data"><date></td> |
|---|
| 166 | <td colspan="2"> |
|---|
| 167 | Set survey date of legs: date is a 2 byte little-endian unsigned integer |
|---|
| 168 | counting days from the start of 1900.</td> |
|---|
| 169 | <td class="version">≥8</td> |
|---|
| 170 | </tr> |
|---|
| 171 | <tr> |
|---|
| 172 | <td class="code">0x12</td> |
|---|
| 173 | <td class="type">DATE</td> |
|---|
| 174 | <td class="data"><date1><datespan></td> |
|---|
| 175 | <td colspan="2"> |
|---|
| 176 | Set survey date of legs to a range: date1 is a |
|---|
| 177 | 2 byte little-endian unsigned integer counting days since the start of |
|---|
| 178 | 1900, and datespan is an unsigned byte counting days from date1.</td> |
|---|
| 179 | <td class="version">≥8</td> |
|---|
| 180 | </tr> |
|---|
| 181 | <tr> |
|---|
| 182 | <td class="code">0x13</td> |
|---|
| 183 | <td class="type">DATE</td> |
|---|
| 184 | <td class="data"><date1><date2></td> |
|---|
| 185 | <td colspan="2"> |
|---|
| 186 | Set survey date of legs to a range: date1, date2 are |
|---|
| 187 | 2 byte little-endian unsigned integers counting days since the |
|---|
| 188 | start of 1900.</td> |
|---|
| 189 | <td class="version">≥8</td> |
|---|
| 190 | </tr> |
|---|
| 191 | <tr class="reserved"> |
|---|
| 192 | <td class="code">0x14 - 0x1e</td> |
|---|
| 193 | <td class="type"> </td> |
|---|
| 194 | <td class="data"> </td> |
|---|
| 195 | <td colspan="3">Reserved</td> |
|---|
| 196 | </tr> |
|---|
| 197 | <tr> |
|---|
| 198 | <td class="code">0x1f</td> |
|---|
| 199 | <td class="type">ERROR</td> |
|---|
| 200 | <td class="data"><legs><length><E><H><V></td> |
|---|
| 201 | <td colspan="2"> |
|---|
| 202 | Error information for the current traverse. <legs> is the number of |
|---|
| 203 | legs. <length> is the total length of the |
|---|
| 204 | traverse in cm (0.01m). E, H and V are the error and the horizontal and |
|---|
| 205 | vertical components in cm. (All values are 4 byte little-endian signed integers) </td> |
|---|
| 206 | <td class="version">≥8</td> |
|---|
| 207 | </tr> |
|---|
| 208 | <tr class="reserved"> |
|---|
| 209 | <td class="code">0x20 - 0x2f</td> |
|---|
| 210 | <td class="type"> </td> |
|---|
| 211 | <td class="data"> </td> |
|---|
| 212 | <td colspan="3">Reserved</td> |
|---|
| 213 | </tr> |
|---|
| 214 | <tr> |
|---|
| 215 | <td class="code" rowspan="3">0x30 - 0x31</td> |
|---|
| 216 | <td class="type" rowspan="3">XSECT</td> |
|---|
| 217 | <td class="data" rowspan="3"><label> <L> <R> <U> <D></td> |
|---|
| 218 | <td colspan="2"> |
|---|
| 219 | Modify the current label buffer according to <label> (see below for |
|---|
| 220 | details). The updated contents of the label buffer give the full name of |
|---|
| 221 | the survey station which these dimensions were measured at. Dimensions are |
|---|
| 222 | 2 byte little-endian signed integers representing values in centimetres |
|---|
| 223 | (0.01 metres). Omitted dimensions are encoded as 0xffff. Station flags are |
|---|
| 224 | (N & 0x01): |
|---|
| 225 | </td> |
|---|
| 226 | <td class="version" rowspan="3">≥8</td> |
|---|
| 227 | </tr> |
|---|
| 228 | <tr> |
|---|
| 229 | <th>Flag (N & 0x01)</th> |
|---|
| 230 | <th>Meaning</th> |
|---|
| 231 | </tr> |
|---|
| 232 | <tr> |
|---|
| 233 | <td>0x01</td> |
|---|
| 234 | <td>Station is last one in this passage</td> |
|---|
| 235 | </tr> |
|---|
| 236 | <tr> |
|---|
| 237 | <td class="code" rowspan="3">0x32 - 0x33</td> |
|---|
| 238 | <td class="type" rowspan="3">XSECT</td> |
|---|
| 239 | <td class="data" rowspan="3"><label> <L> <R> <U> <D></td> |
|---|
| 240 | <td colspan="2"> |
|---|
| 241 | Modify the current label buffer according to <label> (see below for |
|---|
| 242 | details). The updated contents of the label buffer give the full name of |
|---|
| 243 | the survey station which these dimensions were measured at. Dimensions are |
|---|
| 244 | 4 byte little-endian signed integers representing values in centimetres |
|---|
| 245 | (0.01 metres). Omitted dimensions are encoded as 0xffffffff. |
|---|
| 246 | </td> |
|---|
| 247 | <td class="version" rowspan="3">≥8</td> |
|---|
| 248 | </tr> |
|---|
| 249 | <tr> |
|---|
| 250 | <th>Flag (N & 0x01)</th> |
|---|
| 251 | <th>Meaning</th> |
|---|
| 252 | </tr> |
|---|
| 253 | <tr> |
|---|
| 254 | <td>0x01</td> |
|---|
| 255 | <td>Station is last one in this passage</td> |
|---|
| 256 | </tr> |
|---|
| 257 | <tr class="reserved"> |
|---|
| 258 | <td class="code">0x34 - 0x3f</td> |
|---|
| 259 | <td class="type"> </td> |
|---|
| 260 | <td class="data"> </td> |
|---|
| 261 | <td colspan="3">Reserved</td> |
|---|
| 262 | </tr> |
|---|
| 263 | <!-- Checked to here! --> |
|---|
| 264 | <tr> |
|---|
| 265 | <td class="code" rowspan="8">0x40 - 0x7f</td> |
|---|
| 266 | <td class="type" rowspan="8">LINE</td> |
|---|
| 267 | <td class="data" rowspan="8"><label> <x> <y> <z></td> |
|---|
| 268 | <td colspan="2"> |
|---|
| 269 | Modify the current label buffer according to <label> (see below for |
|---|
| 270 | details) - if <label> is omitted due to flag bit 0x20 being set then |
|---|
| 271 | the current label buffer is used unmodified. The updated contents of the |
|---|
| 272 | label buffer give the survey that the leg is in. Return leg from current |
|---|
| 273 | position to coordinates given, and update current position to coordinates |
|---|
| 274 | given. |
|---|
| 275 | </td> |
|---|
| 276 | <td class="version" rowspan="5">≥8</td> |
|---|
| 277 | </tr> |
|---|
| 278 | <tr> |
|---|
| 279 | <th>Flag (N & 0x3f)</th> |
|---|
| 280 | <th>Meaning</th> |
|---|
| 281 | </tr> |
|---|
| 282 | <tr> |
|---|
| 283 | <td>0x01</td> |
|---|
| 284 | <td>Leg is above ground</td> |
|---|
| 285 | </tr> |
|---|
| 286 | <tr> |
|---|
| 287 | <td>0x02</td> |
|---|
| 288 | <td>Leg duplicates data in another leg (e.g. resurvey along a passage to |
|---|
| 289 | tie into a known station)</td> |
|---|
| 290 | </tr> |
|---|
| 291 | <tr> |
|---|
| 292 | <td>0x04</td> |
|---|
| 293 | <td>Leg is a splay shot in a chamber (radial shots from a central point)</td> |
|---|
| 294 | </tr> |
|---|
| 295 | <tr class="reserved"> |
|---|
| 296 | <td>0x08</td> |
|---|
| 297 | <td colspan="2">Reserved</td> |
|---|
| 298 | </tr> |
|---|
| 299 | <tr class="reserved"> |
|---|
| 300 | <td>0x10</td> |
|---|
| 301 | <td colspan="2">Reserved</td> |
|---|
| 302 | </tr> |
|---|
| 303 | <tr> |
|---|
| 304 | <td>0x20</td> |
|---|
| 305 | <td>No change to label (<label> omitted entirely)</td> |
|---|
| 306 | <td class="version">≥8</td> |
|---|
| 307 | </tr> |
|---|
| 308 | <tr> |
|---|
| 309 | <td class="code" rowspan="10">0x80 - 0xff</td> |
|---|
| 310 | <td class="type" rowspan="10">LABEL</td> |
|---|
| 311 | <td class="data" rowspan="10"><label> <x> <y> <z></td> |
|---|
| 312 | <td colspan="2"> |
|---|
| 313 | Modify the current label buffer according to <label> (see below for |
|---|
| 314 | details). The updated contents of the label buffer give the survey |
|---|
| 315 | station's full name. |
|---|
| 316 | </td> |
|---|
| 317 | <td class="version" rowspan="10">≥8</td> |
|---|
| 318 | </tr> |
|---|
| 319 | <tr> |
|---|
| 320 | <td colspan="2"> |
|---|
| 321 | The station flags are encoded in the bottom 7 bits of the item code:</td> |
|---|
| 322 | </tr> |
|---|
| 323 | <tr> |
|---|
| 324 | <th>Flag (N & 0x7f)</th> |
|---|
| 325 | <th>Meaning</th> |
|---|
| 326 | </tr> |
|---|
| 327 | <tr> |
|---|
| 328 | <td>0x01</td> |
|---|
| 329 | <td>Station is on leg above ground</td> |
|---|
| 330 | </tr> |
|---|
| 331 | <tr> |
|---|
| 332 | <td>0x02</td> |
|---|
| 333 | <td>Station is on an underground leg (both may be true at an entrance)</td> |
|---|
| 334 | </tr> |
|---|
| 335 | <tr> |
|---|
| 336 | <td>0x04</td> |
|---|
| 337 | <td>Station is marked as an entrance (with *entrance)</td> |
|---|
| 338 | </tr> |
|---|
| 339 | <tr> |
|---|
| 340 | <td>0x08</td> |
|---|
| 341 | <td>Station is exported (i.e. may be used as a connection point to other |
|---|
| 342 | surveys)</td> |
|---|
| 343 | </tr> |
|---|
| 344 | <tr> |
|---|
| 345 | <td>0x10</td> |
|---|
| 346 | <td>Station is a fixed point (control point)</td> |
|---|
| 347 | </tr> |
|---|
| 348 | <tr> |
|---|
| 349 | <td>0x20</td> |
|---|
| 350 | <td>Station is anonymous</td> |
|---|
| 351 | </tr> |
|---|
| 352 | <tr> |
|---|
| 353 | <td>0x40</td> |
|---|
| 354 | <td>Station is on the passage wall</td> |
|---|
| 355 | </tr> |
|---|
| 356 | </table> |
|---|
| 357 | |
|---|
| 358 | <p>A <label> value in the table above encodes modifications to the |
|---|
| 359 | current label buffer, which consist of removing the last <i>D</i> bytes |
|---|
| 360 | from the buffer, and then appending the next <i>A</i> bytes from the file |
|---|
| 361 | to the buffer. <i>D</i> and <i>A</i> are encoded as follows:</p> |
|---|
| 362 | |
|---|
| 363 | <ul> |
|---|
| 364 | <li>Read a byte - if it is non-zero then: <i>D</i> = <code>byte >> 4</code>, <i>A</i> = <code>byte & 0x0f</code> |
|---|
| 365 | <li>Otherwise (i.e. the first byte is zero): |
|---|
| 366 | <ul> |
|---|
| 367 | <li>Read a byte and: |
|---|
| 368 | <ul> |
|---|
| 369 | <li>If it is not 255 then <i>D</i> = <code>byte</code> |
|---|
| 370 | <li>Otherwise, <i>D</i> = 4 byte unsigned integer read from the file |
|---|
| 371 | </ul> |
|---|
| 372 | <li>Read a byte and: |
|---|
| 373 | <ul> |
|---|
| 374 | <li>If it is not 255 then <i>A</i> = <code>byte</code> |
|---|
| 375 | <li>Otherwise, <i>A</i> = 4 byte unsigned integer read from the file |
|---|
| 376 | </ul> |
|---|
| 377 | </ul> |
|---|
| 378 | </ul> |
|---|
| 379 | |
|---|
| 380 | <H2>Item order</H2> |
|---|
| 381 | <ul> |
|---|
| 382 | <li>A continuous section of centreline is defined by a <MOVE> item, followed |
|---|
| 383 | by one or more <LINE> items.</li> |
|---|
| 384 | <li><LABEL> items may appear anywhere in the file after the header, |
|---|
| 385 | including within a <MOVE><LINE>... sequence.</li> |
|---|
| 386 | <li>Duplicate <LABEL> items are permitted provided they also have identical |
|---|
| 387 | coordinate values. (The same coordinate values may also be shared by any |
|---|
| 388 | number of different <LABEL> items).</li> |
|---|
| 389 | <li>Stations must be defined in a <LABEL> item <u>before</u> being |
|---|
| 390 | referenced (e.g. in <XSECT> items)</li> |
|---|
| 391 | </ul> |
|---|
| 392 | |
|---|
| 393 | <P>Authors: Olly Betts and Mike McCombe, last updated: 2025-01-13</P> |
|---|
| 394 | </BODY></HTML> |
|---|