source: git/doc/3dformat.htm @ 6db8343

stereo-2025
Last change on this file since 6db8343 was adb5b75, checked in by Olly Betts <olly@…>, 6 months ago

Improve wording in docs a little

  • Property mode set to 100644
File size: 13.8 KB
RevLine 
[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]5BODY, TD, TH, CENTER, UL, OL {font-family: sans-serif;}
6TD, TH {font-size: 11pt; vertical-align: top;}
7TH {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;}
13TH.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
21that you use the img routine provided with Survex to read and write
223d files.  Doing so means that you can take advantage of any revisions
23to the 3d format by simply rebuilding your software with the updated
24img routines, rather than having to update your own code.  It also
[adb5b75]25allows you to read other processed survey data formats (those from
26Larry Fish's Compass and from Bob Thrun's CMAP), and allows reading
27a sub-set of the data in a file, restricted by survey prefix.</P>
[2d82f2a]28
[ec812baa]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
31href="3dformat-old.htm">separate document</a> describes older versions.
32</P>
[618b01f]33
34<P>If you try to use this specification and find details which aren't
35spelled out clearly enough (or at all!) or any errors, please let us know.
36At least two people have successfully written code to read 3d files
37using this document, but that doesn't mean it can't be improved.
38</P>
[2d82f2a]39
40<H2>File Header</H2>
41
[618b01f]42<P>This consists of:</P>
[2d82f2a]43
44<ul>
[afe350e]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
[618b01f]47before this and other linefeeds - this is a file format error in any
48other format version].
[ec812baa]49<li> File format version: "v8" followed by a linefeed.
50Any future versions will be "v9", "v10", "v11", etc.
[17ec06d]51<li> Assorted string metadata - the sublist below lists these, and they
52must appear in the order given, separated by zero bytes, with the end of
53the metadata marked by a linefeed.  More items may be added, so ignore any
54additional ones which are present.  Any trailing items with empty values
55can 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.
58There's no length limit on this string.
[cf62988]59  <li>Coordinate system: string describing the coordinate system in use
60which can be passed to PROJ.  For a coordinate system with an EPSG code
[52a6209]61<code>EPSG:</code> followed by the code number can be used (we recommend
62using this if an EPSG code exists).  Similarly, an ESRI code can be specified
63with <code>ESRI:</code> followed by the code number.
[5d59477]64  <li>Survey hierarchy separator character.  Survey station names form a
65hierarchy, 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
67specified, which is also the recommended character to use unless <code>.</code>
68is used in survey or station names (especially as older software will not see
69this metadata and will use <code>.</code> unconditionally).
[17ec06d]70 </ul>
[ec812baa]71<li> Timestamp: A string consisting of an '@' followed by a count of
72seconds 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
74the time the file was generated, rather than the time the survey data was
75collected.
[73fea40]76<li> File-wide flags: a single byte.  If bit 7 is set, this is an extended
77elevation.  All other bits are reserved - set them to 0 when writing, and
78ignore them when reading.
[2d82f2a]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
84byte when the current label is empty, which marks the end of the data.  The
[618b01f]85first byte of an item is a code identifying what the item is:</P>
[760a6550]86
[618b01f]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>
[dec6b10]97    <td class="type">STYLE_NORMAL / STOP</td>
[618b01f]98    <td class="data">&nbsp;</td>
[dec6b10]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>
[ec812baa]104    <td class="version">&ge;8</td>
[618b01f]105</tr>
106<tr>
[dec6b10]107    <td class="code">0x01</td>
108    <td class="type">STYLE_DIVING</td>
[618b01f]109    <td class="data">&nbsp;</td>
[dec6b10]110    <td colspan="2">
111    Set style for following legs to diving data</td>
112    <td class="version">&ge;8</td>
113</tr>
114<tr>
115    <td class="code">0x02</td>
116    <td class="type">STYLE_CARTESIAN</td>
117    <td class="data">&nbsp;</td>
118    <td colspan="2">
119    Set style for following legs to cartesian data</td>
120    <td class="version">&ge;8</td>
121</tr>
122<tr>
123    <td class="code">0x03</td>
124    <td class="type">STYLE_CYLPOLAR</td>
125    <td class="data">&nbsp;</td>
126    <td colspan="2">
127    Set style for following legs to cylindrical polar data</td>
[ec812baa]128    <td class="version">&ge;8</td>
[618b01f]129</tr>
[dec6b10]130<tr>
131    <td class="code">0x04</td>
132    <td class="type">STYLE_NOSURVEY</td>
133    <td class="data">&nbsp;</td>
134    <td colspan="2">
135    Set style for following legs to unsurveyed</td>
136    <td class="version">&ge;8</td>
137</tr>
138<tr class="reserved">
139    <td class="code">0x05 - 0x0e</td>
140    <td class="type">&nbsp;</td>
141    <td class="data">&nbsp;</td>
142    <td class="desc" colspan="3">Reserved</td>
143</tr>
[618b01f]144<tr>
145    <td class="code">0x0f</td>
146    <td class="type">MOVE</td>
147    <td class="data">&lt;x&gt; &lt;y&gt; &lt;z&gt;</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>
[ec812baa]152    <td class="version">&ge;8</td>
[618b01f]153</tr>
[22114ef]154<tr>
155    <td class="code">0x10</td>
156    <td class="type">DATE</td>
[618b01f]157    <td class="data">&nbsp;</td>
[22114ef]158    <td colspan="2">
159    No survey date information was specified.</td>
160    <td class="version">&ge;8</td>
[618b01f]161</tr>
162<tr>
[22114ef]163    <td class="code">0x11</td>
[618b01f]164    <td class="type">DATE</td>
[1ee204e]165    <td class="data">&lt;date&gt;</td>
166    <td colspan="2">
[0cf46f5]167    Set survey date of legs: date is a 2 byte little-endian unsigned integer
[22114ef]168    counting days from the start of 1900.</td>
[ec812baa]169    <td class="version">&ge;8</td>
[1ee204e]170</tr>
171<tr>
[22114ef]172    <td class="code">0x12</td>
[1ee204e]173    <td class="type">DATE</td>
174    <td class="data">&lt;date1&gt;&lt;datespan&gt;</td>
175    <td colspan="2">
[0cf46f5]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>
[ec812baa]179    <td class="version">&ge;8</td>
[618b01f]180</tr>
[1599605]181<tr>
[22114ef]182    <td class="code">0x13</td>
[1ee204e]183    <td class="type">DATE</td>
184    <td class="data">&lt;date1&gt;&lt;date2&gt;</td>
185    <td colspan="2">
[0cf46f5]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>
[ec812baa]189    <td class="version">&ge;8</td>
[1ee204e]190</tr>
[22114ef]191<tr class="reserved">
192    <td class="code">0x14 - 0x1e</td>
193    <td class="type">&nbsp;</td>
[1ee204e]194    <td class="data">&nbsp;</td>
[22114ef]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">&lt;legs&gt;&lt;length&gt;&lt;E&gt;&lt;H&gt;&lt;V&gt;</td>
[1ee204e]201    <td colspan="2">
[22114ef]202    Error information for the current traverse.  &lt;legs&gt; is the number of
203    legs. &lt;length&gt; 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>
[ec812baa]206    <td class="version">&ge;8</td>
[1ee204e]207</tr>
[618b01f]208<tr class="reserved">
[22114ef]209    <td class="code">0x20 - 0x2f</td>
[618b01f]210    <td class="type">&nbsp;</td>
211    <td class="data">&nbsp;</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>
[dec6b10]217    <td class="data" rowspan="3">&lt;label&gt; &lt;L&gt; &lt;R&gt; &lt;U&gt; &lt;D&gt;</td>
[618b01f]218    <td colspan="2">
[589c6ec]219    Modify the current label buffer according to &lt;label&gt; (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 &amp; 0x01):
225    </td>
[ec812baa]226    <td class="version" rowspan="3">&ge;8</td>
[618b01f]227</tr>
228<tr>
229    <th>Flag (N &amp; 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>
[dec6b10]239    <td class="data" rowspan="3">&lt;label&gt; &lt;L&gt; &lt;R&gt; &lt;U&gt; &lt;D&gt;</td>
[618b01f]240    <td colspan="2">
[589c6ec]241    Modify the current label buffer according to &lt;label&gt; (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>
[ec812baa]247    <td class="version" rowspan="3">&ge;8</td>
[618b01f]248</tr>
249<tr>
250    <th>Flag (N &amp; 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">&nbsp;</td>
260    <td class="data">&nbsp;</td>
261    <td colspan="3">Reserved</td>
262</tr>
263<!-- Checked to here! -->
264<tr>
[dec6b10]265    <td class="code" rowspan="8">0x40 - 0x7f</td>
266    <td class="type" rowspan="8">LINE</td>
267    <td class="data" rowspan="8">&lt;label&gt; &lt;x&gt; &lt;y&gt; &lt;z&gt;</td>
268    <td colspan="2">
[589c6ec]269    Modify the current label buffer according to &lt;label&gt; (see below for
270    details) - if &lt;label&gt; 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>
[dec6b10]276    <td class="version" rowspan="5">&ge;8</td>
277</tr>
278<tr>
279    <th>Flag (N &amp; 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>
[e133186]303<tr>
[dec6b10]304    <td>0x20</td>
[e133186]305    <td>No change to label (&lt;label&gt; omitted entirely)</td>
306    <td class="version">&ge;8</td>
[dec6b10]307</tr>
308<tr>
[589c6ec]309    <td class="code" rowspan="10">0x80 - 0xff</td>
310    <td class="type" rowspan="10">LABEL</td>
311    <td class="data" rowspan="10">&lt;label&gt; &lt;x&gt; &lt;y&gt; &lt;z&gt;</td>
[618b01f]312    <td colspan="2">
[589c6ec]313    Modify the current label buffer according to &lt;label&gt; (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">&ge;8</td>
[618b01f]318</tr>
319<tr>
320    <td colspan="2">
[dec6b10]321    The station flags are encoded in the bottom 7 bits of the item code:</td>
[618b01f]322</tr>
323<tr>
[dec6b10]324    <th>Flag (N &amp; 0x7f)</th>
[618b01f]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>
[dec6b10]350    <td>Station is anonymous</td>
[618b01f]351</tr>
[dec6b10]352<tr>
353    <td>0x40</td>
354    <td>Station is on the passage wall</td>
[618b01f]355</tr>
356</table>
[e77d6de]357
[de844aa2]358<p>A &lt;label&gt; value in the table above encodes modifications to the
[589c6ec]359current label buffer, which consist of removing the last <i>D</i> bytes
360from the buffer, and then appending the next <i>A</i> bytes from the file
361to 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 &gt;&gt; 4</code>, <i>A</i> = <code>byte &amp; 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
[618b01f]380<H2>Item order</H2>
[2d82f2a]381<ul>
[618b01f]382<li>A continuous section of centreline is defined by a &lt;MOVE&gt; item, followed
383by one or more &lt;LINE&gt; items.</li>
384<li>&lt;LABEL&gt; items may appear anywhere in the file after the header,
385including within a &lt;MOVE&gt;&lt;LINE&gt;... sequence.</li>
386<li>Duplicate &lt;LABEL&gt; items are permitted provided they also have identical
387coordinate values. (The same coordinate values may also be shared by any
388number of different &lt;LABEL&gt; items).</li>
389<li>Stations must be defined in a &lt;LABEL&gt; item <u>before</u> being
390referenced (e.g. in &lt;XSECT&gt; items)</li>
[2d82f2a]391</ul>
392
[adb5b75]393<P>Authors: Olly Betts and Mike McCombe, last updated: 2025-01-13</P>
[2d82f2a]394</BODY></HTML>
Note: See TracBrowser for help on using the repository browser.