| 1 | <!DOCTYPE HTML PUBLIC "-//W4C//DTD HTML 4.0 Transitional//EN"> |
|---|
| 2 | <HTML><HEAD> |
|---|
| 3 | <TITLE>Survex 3d Format Specification (v3-v7)</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 (v3-v7)</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 3d format revisions 3 to 7 (inclusive). |
|---|
| 30 | Newer versions are described in a <a href="3dformat.htm">separate document</a>. |
|---|
| 31 | Older format versions are only documented by the code to read them in img.c - |
|---|
| 32 | they had version strings "v0.01", "Bv0.01", "bv0.01", and "v2"). |
|---|
| 33 | </P> |
|---|
| 34 | |
|---|
| 35 | <P>The following table document which Survex versions generate which 3d file |
|---|
| 36 | format versions. A version is able to read the format it generates and any |
|---|
| 37 | older versions, but in addition Survex 1.0.40 has support for reading all |
|---|
| 38 | versions up to v7 (but writes v3). |
|---|
| 39 | |
|---|
| 40 | <table border="1" cellpadding="1" cellspacing="0" width="*"> |
|---|
| 41 | <tr> |
|---|
| 42 | <th class="version">Format</th> |
|---|
| 43 | <th class="version" colspan=2>Survex versions</th> |
|---|
| 44 | </tr> |
|---|
| 45 | <tr> |
|---|
| 46 | <td class="version">v3</td> |
|---|
| 47 | <td class="version">0.97</td> |
|---|
| 48 | <td class="version">1.0.40</td> |
|---|
| 49 | </tr> |
|---|
| 50 | <tr> |
|---|
| 51 | <td class="version">v4</td> |
|---|
| 52 | <td class="version">1.1.0</td> |
|---|
| 53 | <td class="version">1.1.3</td> |
|---|
| 54 | </tr> |
|---|
| 55 | <tr> |
|---|
| 56 | <td class="version">v5</td> |
|---|
| 57 | <td class="version">1.1.4</td> |
|---|
| 58 | <td class="version">1.1.10</td> |
|---|
| 59 | </tr> |
|---|
| 60 | <tr> |
|---|
| 61 | <td class="version">v6</td> |
|---|
| 62 | <td class="version">1.1.11</td> |
|---|
| 63 | <td class="version">1.1.14</td> |
|---|
| 64 | </tr> |
|---|
| 65 | <tr> |
|---|
| 66 | <td class="version">v7</td> |
|---|
| 67 | <td class="version">1.1.15</td> |
|---|
| 68 | <td class="version">1.2.6</td> |
|---|
| 69 | </tr> |
|---|
| 70 | </table> |
|---|
| 71 | |
|---|
| 72 | <P>If you try to use this specification and find details which aren't |
|---|
| 73 | spelled out clearly enough (or at all!) or any errors, please let us know. |
|---|
| 74 | At least two people have successfully written code to read 3d files |
|---|
| 75 | using this document, but that doesn't mean it can't be improved. |
|---|
| 76 | </P> |
|---|
| 77 | |
|---|
| 78 | <H2>File Header</H2> |
|---|
| 79 | |
|---|
| 80 | <P>This consists of:</P> |
|---|
| 81 | |
|---|
| 82 | <ul> |
|---|
| 83 | <li>File ID: the string "Survex 3D Image File" followed by a linefeed |
|---|
| 84 | (decimal 10, hex 0a). [Note: v0.01 files can have a carriage return |
|---|
| 85 | before this and other linefeeds - this is a file format error in any |
|---|
| 86 | other format version]. |
|---|
| 87 | <li>File format version: "v3", "v4", "v5", "v6", "v7" followed by a linefeed. |
|---|
| 88 | Any future versions will be "v8", "v9", "v10", "v11", etc. |
|---|
| 89 | <li> Survey title: A string followed by a linefeed. There's no length limit on this string. |
|---|
| 90 | <li> Timestamp: A string followed by a linefeed. This is intended to be the |
|---|
| 91 | time the file was generated, rather than the time the survey data was |
|---|
| 92 | collected. The easiest way to generate this is with the strftime() format |
|---|
| 93 | "%a,%Y.%m.%d %H:%M:%S %Z" if you have access to strftime(). An example |
|---|
| 94 | timestamp is "Sun,2002.03.17 14:01:07 GMT". |
|---|
| 95 | </ul> |
|---|
| 96 | |
|---|
| 97 | <H2>Items</H2> |
|---|
| 98 | |
|---|
| 99 | <P>Following the header are a number of items. The last item must be a 0x00 |
|---|
| 100 | byte when the current label is empty, which marks the end of the data. The |
|---|
| 101 | first byte of an item is a code identifying what the item is:</P> |
|---|
| 102 | |
|---|
| 103 | <table border="1" cellpadding="1" cellspacing="0" width="100%"> |
|---|
| 104 | <tr> |
|---|
| 105 | <th class="code">Code</th> |
|---|
| 106 | <th class="code">Type</th> |
|---|
| 107 | <th class="data">Data</th> |
|---|
| 108 | <th class="desc" colspan="2">Meaning</th> |
|---|
| 109 | <th class="version">Version</th> |
|---|
| 110 | </tr> |
|---|
| 111 | <tr> |
|---|
| 112 | <td class="code">0x00</td> |
|---|
| 113 | <td class="type">STOP</td> |
|---|
| 114 | <td class="data"> </td> |
|---|
| 115 | <td class="desc" colspan="2"> |
|---|
| 116 | If the current label is empty, signifies the end of the data in the 3d |
|---|
| 117 | file; if the current label isn't empty, make it empty.</td> |
|---|
| 118 | <td class="version">≥3</td> |
|---|
| 119 | </tr> |
|---|
| 120 | <tr> |
|---|
| 121 | <td class="code">0x01 - 0x0e</td> |
|---|
| 122 | <td class="type">TRIM</td> |
|---|
| 123 | <td class="data"> </td> |
|---|
| 124 | <td class="desc" colspan="2"> |
|---|
| 125 | Trim the last 16 characters of the current label, then trim back N (i.e. |
|---|
| 126 | 1-14) dots ("."), everything after that particular dot. |
|---|
| 127 | It's incorrect if the label ends up empty, or you attempt to trim more |
|---|
| 128 | label than there is. The rationale for removing 16 characters first is |
|---|
| 129 | that removal of 1-16 characters can be encoded by 0x10-0x1f (see below) |
|---|
| 130 | and we can make this encoding more powerful by not |
|---|
| 131 | overlapping what can be encoded.</td> |
|---|
| 132 | <td class="version">≥3</td> |
|---|
| 133 | </tr> |
|---|
| 134 | <tr> |
|---|
| 135 | <td class="code">0x0f</td> |
|---|
| 136 | <td class="type">MOVE</td> |
|---|
| 137 | <td class="data"><x> <y> <z></td> |
|---|
| 138 | <td class="desc" colspan="2"> |
|---|
| 139 | Set current position to the coordinates given. Coordinates |
|---|
| 140 | are 4 byte little-endian signed integers representing |
|---|
| 141 | values in centimetres (0.01 metres).</td> |
|---|
| 142 | <td class="version">≥3</td> |
|---|
| 143 | </tr> |
|---|
| 144 | <tr> |
|---|
| 145 | <td class="code">0x10 - 0x1f</td> |
|---|
| 146 | <td class="type">TRIM</td> |
|---|
| 147 | <td class="data"> </td> |
|---|
| 148 | <td colspan="2"> |
|---|
| 149 | Remove N-15 (i.e. 1-16) characters from the current label. It's |
|---|
| 150 | incorrect if the label ends up empty, or you attempt to trim more label |
|---|
| 151 | than there is.</td> |
|---|
| 152 | <td class="version">≥3</td> |
|---|
| 153 | </tr> |
|---|
| 154 | <tr> |
|---|
| 155 | <td class="code">0x20</td> |
|---|
| 156 | <td class="type">DATE (old version)</td> |
|---|
| 157 | <td class="data"><date></td> |
|---|
| 158 | <td colspan="2"> |
|---|
| 159 | Set survey date of legs: date is 4 byte little-endian unsigned integer |
|---|
| 160 | counting seconds since 1970.</td> |
|---|
| 161 | <td class="version">≥4 and ≤6</td> |
|---|
| 162 | </tr> |
|---|
| 163 | <tr> |
|---|
| 164 | <td class="code">0x20</td> |
|---|
| 165 | <td class="type">DATE</td> |
|---|
| 166 | <td class="data"><date></td> |
|---|
| 167 | <td colspan="2"> |
|---|
| 168 | Set survey date of legs: date is a 2 byte little-endian unsigned integer |
|---|
| 169 | counting days from the |
|---|
| 170 | start of 1900.</td> |
|---|
| 171 | <td class="version">≥7</td> |
|---|
| 172 | </tr> |
|---|
| 173 | <tr> |
|---|
| 174 | <td class="code">0x21</td> |
|---|
| 175 | <td class="type">DATE (old version)</td> |
|---|
| 176 | <td class="data"><date1><date2></td> |
|---|
| 177 | <td colspan="2"> |
|---|
| 178 | Set survey date of legs to a range: date1, date2 are 4 byte little-endian |
|---|
| 179 | unsigned integer counting seconds since 1970.</td> |
|---|
| 180 | <td class="version">≥4 and ≤6</td> |
|---|
| 181 | </tr> |
|---|
| 182 | <tr> |
|---|
| 183 | <td class="code">0x21</td> |
|---|
| 184 | <td class="type">DATE</td> |
|---|
| 185 | <td class="data"><date1><datespan></td> |
|---|
| 186 | <td colspan="2"> |
|---|
| 187 | Set survey date of legs to a range: date1 is a |
|---|
| 188 | 2 byte little-endian unsigned integer counting days since the start of |
|---|
| 189 | 1900, and datespan is an unsigned byte counting days from date1.</td> |
|---|
| 190 | <td class="version">≥7</td> |
|---|
| 191 | </tr> |
|---|
| 192 | <tr> |
|---|
| 193 | <td class="code">0x22</td> |
|---|
| 194 | <td class="type">ERROR</td> |
|---|
| 195 | <td class="data"><legs><length><E><H><V></td> |
|---|
| 196 | <td colspan="2"> |
|---|
| 197 | Error information for the current traverse. <legs> is the number of |
|---|
| 198 | legs. <length> is the total length of the |
|---|
| 199 | traverse in cm (0.01m). E, H and V are the error and the horizontal and |
|---|
| 200 | vertical components in cm. (All values are 4 byte little-endian signed integers) </td> |
|---|
| 201 | <td class="version">≥6</td> |
|---|
| 202 | </tr> |
|---|
| 203 | <tr> |
|---|
| 204 | <td class="code">0x23</td> |
|---|
| 205 | <td class="type">DATE</td> |
|---|
| 206 | <td class="data"><date1><date2></td> |
|---|
| 207 | <td colspan="2"> |
|---|
| 208 | Set survey date of legs to a range: date1, date2 are |
|---|
| 209 | 2 byte little-endian unsigned integers counting days since the |
|---|
| 210 | start of 1900.</td> |
|---|
| 211 | <td class="version">≥7</td> |
|---|
| 212 | </tr> |
|---|
| 213 | <tr> |
|---|
| 214 | <td class="code">0x24</td> |
|---|
| 215 | <td class="type">DATE</td> |
|---|
| 216 | <td class="data"> </td> |
|---|
| 217 | <td colspan="2"> |
|---|
| 218 | No survey date information was specified.</td> |
|---|
| 219 | <td class="version">≥7</td> |
|---|
| 220 | </tr> |
|---|
| 221 | <tr class="reserved"> |
|---|
| 222 | <td class="code">0x25 - 0x2f</td> |
|---|
| 223 | <td class="type"> </td> |
|---|
| 224 | <td class="data"> </td> |
|---|
| 225 | <td colspan="3">Reserved</td> |
|---|
| 226 | </tr> |
|---|
| 227 | <tr> |
|---|
| 228 | <td class="code" rowspan="3">0x30 - 0x31</td> |
|---|
| 229 | <td class="type" rowspan="3">XSECT</td> |
|---|
| 230 | <td class="data" rowspan="3"><len> <label> <L> <R> <U> <D></td> |
|---|
| 231 | <td colspan="2"> |
|---|
| 232 | Dimensions are 2 byte little-endian signed integers representing values |
|---|
| 233 | in centimetres (0.01 metres). Omitted dimensions are encoded as 0xffff. |
|---|
| 234 | Station flags are (N & 0x01): </td> |
|---|
| 235 | <td class="version" rowspan="3">≥5</td> |
|---|
| 236 | </tr> |
|---|
| 237 | <tr> |
|---|
| 238 | <th>Flag (N & 0x01)</th> |
|---|
| 239 | <th>Meaning</th> |
|---|
| 240 | </tr> |
|---|
| 241 | <tr> |
|---|
| 242 | <td>0x01</td> |
|---|
| 243 | <td>Station is last one in this passage</td> |
|---|
| 244 | </tr> |
|---|
| 245 | <tr> |
|---|
| 246 | <td class="code" rowspan="3">0x32 - 0x33</td> |
|---|
| 247 | <td class="type" rowspan="3">XSECT</td> |
|---|
| 248 | <td class="data" rowspan="3"><len> <label> <L> <R> <U> <D></td> |
|---|
| 249 | <td colspan="2"> |
|---|
| 250 | Dimensions are 4 byte little-endian signed integers representing values |
|---|
| 251 | in centimetres (0.01 metres). Omitted dimensions are encoded as |
|---|
| 252 | 0xffffffff.</td> |
|---|
| 253 | <td class="version" rowspan="3">≥5</td> |
|---|
| 254 | </tr> |
|---|
| 255 | <tr> |
|---|
| 256 | <th>Flag (N & 0x01)</th> |
|---|
| 257 | <th>Meaning</th> |
|---|
| 258 | </tr> |
|---|
| 259 | <tr> |
|---|
| 260 | <td>0x01</td> |
|---|
| 261 | <td>Station is last one in this passage</td> |
|---|
| 262 | </tr> |
|---|
| 263 | <tr class="reserved"> |
|---|
| 264 | <td class="code">0x34 - 0x3f</td> |
|---|
| 265 | <td class="type"> </td> |
|---|
| 266 | <td class="data"> </td> |
|---|
| 267 | <td colspan="3">Reserved</td> |
|---|
| 268 | </tr> |
|---|
| 269 | <!-- Checked to here! --> |
|---|
| 270 | <tr> |
|---|
| 271 | <td class="code" rowspan="13">0x40 - 0x7f</td> |
|---|
| 272 | <td class="type" rowspan="13">LABEL</td> |
|---|
| 273 | <td class="data" rowspan="13"><len> <label> <x> <y> <z></td> |
|---|
| 274 | <td colspan="2"> |
|---|
| 275 | Append label to the current label buffer. The updated contents of the |
|---|
| 276 | label buffer give the survey stations full name. The length of label is |
|---|
| 277 | given by length, which is encoded as follows:</td> |
|---|
| 278 | <td class="version" rowspan="12">≥3</td> |
|---|
| 279 | </tr> |
|---|
| 280 | <tr> |
|---|
| 281 | <th>Length</th> |
|---|
| 282 | <th>Encoding</th> |
|---|
| 283 | </tr> |
|---|
| 284 | <tr> |
|---|
| 285 | <td>0 - 253</td> |
|---|
| 286 | <td>byte 0x00 - 0xfd</td> |
|---|
| 287 | </tr> |
|---|
| 288 | <tr> |
|---|
| 289 | <td>254-65789</td> |
|---|
| 290 | <td>byte 0xfe 2 byte little-endian unsigned integer len-254 0x0000-0xffff</td> |
|---|
| 291 | </tr> |
|---|
| 292 | <tr> |
|---|
| 293 | <td>65790 and greater</td> |
|---|
| 294 | <td>byte 0xff 4 byte little-endian unsigned integer len |
|---|
| 295 | 0x000100fd-0xffffffff</td> |
|---|
| 296 | </tr> |
|---|
| 297 | <tr> |
|---|
| 298 | <td colspan="2"> |
|---|
| 299 | The station flags are encoded in the bottom 6 bits of the item code:</td> |
|---|
| 300 | </tr> |
|---|
| 301 | <tr> |
|---|
| 302 | <th>Flag (N & 0x3f)</th> |
|---|
| 303 | <th>Meaning</th> |
|---|
| 304 | </tr> |
|---|
| 305 | <tr> |
|---|
| 306 | <td>0x01</td> |
|---|
| 307 | <td>Station is on leg above ground</td> |
|---|
| 308 | </tr> |
|---|
| 309 | <tr> |
|---|
| 310 | <td>0x02</td> |
|---|
| 311 | <td>Station is on an underground leg (both may be true at an entrance)</td> |
|---|
| 312 | </tr> |
|---|
| 313 | <tr> |
|---|
| 314 | <td>0x04</td> |
|---|
| 315 | <td>Station is marked as an entrance (with *entrance)</td> |
|---|
| 316 | </tr> |
|---|
| 317 | <tr> |
|---|
| 318 | <td>0x08</td> |
|---|
| 319 | <td>Station is exported (i.e. may be used as a connection point to other |
|---|
| 320 | surveys)</td> |
|---|
| 321 | </tr> |
|---|
| 322 | <tr> |
|---|
| 323 | <td>0x10</td> |
|---|
| 324 | <td>Station is a fixed point (control point)</td> |
|---|
| 325 | </tr> |
|---|
| 326 | <tr class="reserved"> |
|---|
| 327 | <td>0x20</td> |
|---|
| 328 | <td colspan="2">Reserved</td> |
|---|
| 329 | </tr> |
|---|
| 330 | <tr> |
|---|
| 331 | <td class="code" rowspan="8">0x80 - 0xbf</td> |
|---|
| 332 | <td class="type" rowspan="8">LINE</td> |
|---|
| 333 | <td class="data" rowspan="8"><len> <label> <x> <y> <z></td> |
|---|
| 334 | <td colspan="2"> |
|---|
| 335 | Append label to the current label buffer. The length of the label is |
|---|
| 336 | encoded as for a station label above. Return leg from current position |
|---|
| 337 | to coordinates given, and update current position to coordinates given. |
|---|
| 338 | The updated contents of the label buffer give the survey that the leg is |
|---|
| 339 | in.</td> |
|---|
| 340 | <td class="version" rowspan="5">≥3</td> |
|---|
| 341 | </tr> |
|---|
| 342 | <tr> |
|---|
| 343 | <th>Flag (N & 0x3f)</th> |
|---|
| 344 | <th>Meaning</th> |
|---|
| 345 | </tr> |
|---|
| 346 | <tr> |
|---|
| 347 | <td>0x01</td> |
|---|
| 348 | <td>Leg is above ground</td> |
|---|
| 349 | </tr> |
|---|
| 350 | <tr> |
|---|
| 351 | <td>0x02</td> |
|---|
| 352 | <td>Leg duplicates data in another leg (e.g. resurvey along a passage to |
|---|
| 353 | tie into a known station)</td> |
|---|
| 354 | </tr> |
|---|
| 355 | <tr> |
|---|
| 356 | <td>0x04</td> |
|---|
| 357 | <td>Leg is a splay shot in a chamber (radial shots from a central point)</td> |
|---|
| 358 | </tr> |
|---|
| 359 | <tr class="reserved"> |
|---|
| 360 | <td>0x08</td> |
|---|
| 361 | <td colspan="2">Reserved</td> |
|---|
| 362 | </tr> |
|---|
| 363 | <tr class="reserved"> |
|---|
| 364 | <td>0x10</td> |
|---|
| 365 | <td colspan="2">Reserved</td> |
|---|
| 366 | </tr> |
|---|
| 367 | <tr class="reserved"> |
|---|
| 368 | <td>0x20</td> |
|---|
| 369 | <td colspan="2">Reserved</td> |
|---|
| 370 | </tr> |
|---|
| 371 | <tr class="reserved"> |
|---|
| 372 | <td class="code">0xc0 - 0xff</td> |
|---|
| 373 | <td class="type"> </td> |
|---|
| 374 | <td class="data"> </td> |
|---|
| 375 | <td colspan="3">Reserved</td> |
|---|
| 376 | </tr> |
|---|
| 377 | </table> |
|---|
| 378 | |
|---|
| 379 | <H2>Item order</H2> |
|---|
| 380 | <ul> |
|---|
| 381 | <li>A continuous section of centreline is defined by a <MOVE> item, followed |
|---|
| 382 | by one or more <LINE> items.</li> |
|---|
| 383 | <li><LABEL> items may appear anywhere in the file after the header, |
|---|
| 384 | including within a <MOVE><LINE>... sequence.</li> |
|---|
| 385 | <li>Duplicate <LABEL> items are permitted provided they also have identical |
|---|
| 386 | coordinate values. (The same coordinate values may also be shared by any |
|---|
| 387 | number of different <LABEL> items).</li> |
|---|
| 388 | <li>Stations must be defined in a <LABEL> item <u>before</u> being |
|---|
| 389 | referenced (e.g. in <XSECT> items)</li> |
|---|
| 390 | </ul> |
|---|
| 391 | |
|---|
| 392 | <P>Authors: Olly Betts and Mike McCombe, last updated: 2025-01-13</P> |
|---|
| 393 | </BODY></HTML> |
|---|