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