3dformat.htm: Document ESRI:<number> for CRS:
[survex.git] / doc / 3dformat.htm
blob72e9210f67b1374687b641b1cac0baca3cad9126
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>
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>
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>
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>
39 <H2>File Header</H2>
41 <P>This consists of:</P>
43 <ul>
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
46 before this and other linefeeds - this is a file format error in any
47 other format version].
48 <li> File format version: "v8" followed by a linefeed.
49 Any future versions will be "v9", "v10", "v11", etc.
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.
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
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.
63 </ul>
64 <li> Timestamp: A string consisting of an '@' followed by a count of
65 seconds since the start of 1970 in UTC ("Unix time_t") as a string
66 (for example: "@1371300355"), followed by a linefeed. This is intended to be
67 the time the file was generated, rather than the time the survey data was
68 collected.
69 <li> File-wide flags: a single byte. If bit 7 is set, this is an extended
70 elevation. All other bits are reserved - set them to 0 when writing, and
71 ignore them when reading.
72 </ul>
74 <H2>Items</H2>
76 <P>Following the header are a number of items. The last item must be a 0x00
77 byte when the current label is empty, which marks the end of the data. The
78 first byte of an item is a code identifying what the item is:</P>
80 <table border="1" cellpadding="1" cellspacing="0" width="100%">
81 <tr>
82 <th class="code">Code</th>
83 <th class="code">Type</th>
84 <th class="data">Data</th>
85 <th class="desc" colspan="2">Meaning</th>
86 <th class="version">Version</th>
87 </tr>
88 <tr>
89 <td class="code">0x00</td>
90 <td class="type">STYLE_NORMAL / STOP</td>
91 <td class="data">&nbsp;</td>
92 <td colspan="2">
93 Set style for following legs to tape, compass and clino.
94 <p>
95 If the style is already set to STYLE_NORMAL, this code signifies the
96 end of the data in the 3d file.</td>
97 <td class="version">&ge;8</td>
98 </tr>
99 <tr>
100 <td class="code">0x01</td>
101 <td class="type">STYLE_DIVING</td>
102 <td class="data">&nbsp;</td>
103 <td colspan="2">
104 Set style for following legs to diving data</td>
105 <td class="version">&ge;8</td>
106 </tr>
107 <tr>
108 <td class="code">0x02</td>
109 <td class="type">STYLE_CARTESIAN</td>
110 <td class="data">&nbsp;</td>
111 <td colspan="2">
112 Set style for following legs to cartesian data</td>
113 <td class="version">&ge;8</td>
114 </tr>
115 <tr>
116 <td class="code">0x03</td>
117 <td class="type">STYLE_CYLPOLAR</td>
118 <td class="data">&nbsp;</td>
119 <td colspan="2">
120 Set style for following legs to cylindrical polar data</td>
121 <td class="version">&ge;8</td>
122 </tr>
123 <tr>
124 <td class="code">0x04</td>
125 <td class="type">STYLE_NOSURVEY</td>
126 <td class="data">&nbsp;</td>
127 <td colspan="2">
128 Set style for following legs to unsurveyed</td>
129 <td class="version">&ge;8</td>
130 </tr>
131 <tr class="reserved">
132 <td class="code">0x05 - 0x0e</td>
133 <td class="type">&nbsp;</td>
134 <td class="data">&nbsp;</td>
135 <td class="desc" colspan="3">Reserved</td>
136 </tr>
137 <tr>
138 <td class="code">0x0f</td>
139 <td class="type">MOVE</td>
140 <td class="data">&lt;x&gt; &lt;y&gt; &lt;z&gt;</td>
141 <td class="desc" colspan="2">
142 Set current position to the coordinates given. Coordinates
143 are 4 byte little-endian signed integers representing
144 values in centimetres (0.01 metres).</td>
145 <td class="version">&ge;8</td>
146 </tr>
147 <tr>
148 <td class="code">0x10</td>
149 <td class="type">DATE</td>
150 <td class="data">&nbsp;</td>
151 <td colspan="2">
152 No survey date information was specified.</td>
153 <td class="version">&ge;8</td>
154 </tr>
155 <tr>
156 <td class="code">0x11</td>
157 <td class="type">DATE</td>
158 <td class="data">&lt;date&gt;</td>
159 <td colspan="2">
160 Set survey date of legs: date is a 2 byte little-endian unsigned integer
161 counting days from the start of 1900.</td>
162 <td class="version">&ge;8</td>
163 </tr>
164 <tr>
165 <td class="code">0x12</td>
166 <td class="type">DATE</td>
167 <td class="data">&lt;date1&gt;&lt;datespan&gt;</td>
168 <td colspan="2">
169 Set survey date of legs to a range: date1 is a
170 2 byte little-endian unsigned integer counting days since the start of
171 1900, and datespan is an unsigned byte counting days from date1.</td>
172 <td class="version">&ge;8</td>
173 </tr>
174 <tr>
175 <td class="code">0x13</td>
176 <td class="type">DATE</td>
177 <td class="data">&lt;date1&gt;&lt;date2&gt;</td>
178 <td colspan="2">
179 Set survey date of legs to a range: date1, date2 are
180 2 byte little-endian unsigned integers counting days since the
181 start of 1900.</td>
182 <td class="version">&ge;8</td>
183 </tr>
184 <tr class="reserved">
185 <td class="code">0x14 - 0x1e</td>
186 <td class="type">&nbsp;</td>
187 <td class="data">&nbsp;</td>
188 <td colspan="3">Reserved</td>
189 </tr>
190 <tr>
191 <td class="code">0x1f</td>
192 <td class="type">ERROR</td>
193 <td class="data">&lt;legs&gt;&lt;length&gt;&lt;E&gt;&lt;H&gt;&lt;V&gt;</td>
194 <td colspan="2">
195 Error information for the current traverse. &lt;legs&gt; is the number of
196 legs. &lt;length&gt; is the total length of the
197 traverse in cm (0.01m). E, H and V are the error and the horizontal and
198 vertical components in cm. (All values are 4 byte little-endian signed integers) </td>
199 <td class="version">&ge;8</td>
200 </tr>
201 <tr class="reserved">
202 <td class="code">0x20 - 0x2f</td>
203 <td class="type">&nbsp;</td>
204 <td class="data">&nbsp;</td>
205 <td colspan="3">Reserved</td>
206 </tr>
207 <tr>
208 <td class="code" rowspan="3">0x30 - 0x31</td>
209 <td class="type" rowspan="3">XSECT</td>
210 <td class="data" rowspan="3">&lt;label&gt; &lt;L&gt; &lt;R&gt; &lt;U&gt; &lt;D&gt;</td>
211 <td colspan="2">
212 Modify the current label buffer according to &lt;label&gt; (see below for
213 details). The updated contents of the label buffer give the full name of
214 the survey station which these dimensions were measured at. Dimensions are
215 2 byte little-endian signed integers representing values in centimetres
216 (0.01 metres). Omitted dimensions are encoded as 0xffff. Station flags are
217 (N &amp; 0x01):
218 </td>
219 <td class="version" rowspan="3">&ge;8</td>
220 </tr>
221 <tr>
222 <th>Flag (N &amp; 0x01)</th>
223 <th>Meaning</th>
224 </tr>
225 <tr>
226 <td>0x01</td>
227 <td>Station is last one in this passage</td>
228 </tr>
229 <tr>
230 <td class="code" rowspan="3">0x32 - 0x33</td>
231 <td class="type" rowspan="3">XSECT</td>
232 <td class="data" rowspan="3">&lt;label&gt; &lt;L&gt; &lt;R&gt; &lt;U&gt; &lt;D&gt;</td>
233 <td colspan="2">
234 Modify the current label buffer according to &lt;label&gt; (see below for
235 details). The updated contents of the label buffer give the full name of
236 the survey station which these dimensions were measured at. Dimensions are
237 4 byte little-endian signed integers representing values in centimetres
238 (0.01 metres). Omitted dimensions are encoded as 0xffffffff.
239 </td>
240 <td class="version" rowspan="3">&ge;8</td>
241 </tr>
242 <tr>
243 <th>Flag (N &amp; 0x01)</th>
244 <th>Meaning</th>
245 </tr>
246 <tr>
247 <td>0x01</td>
248 <td>Station is last one in this passage</td>
249 </tr>
250 <tr class="reserved">
251 <td class="code">0x34 - 0x3f</td>
252 <td class="type">&nbsp;</td>
253 <td class="data">&nbsp;</td>
254 <td colspan="3">Reserved</td>
255 </tr>
256 <!-- Checked to here! -->
257 <tr>
258 <td class="code" rowspan="8">0x40 - 0x7f</td>
259 <td class="type" rowspan="8">LINE</td>
260 <td class="data" rowspan="8">&lt;label&gt; &lt;x&gt; &lt;y&gt; &lt;z&gt;</td>
261 <td colspan="2">
262 Modify the current label buffer according to &lt;label&gt; (see below for
263 details) - if &lt;label&gt; is omitted due to flag bit 0x20 being set then
264 the current label buffer is used unmodified. The updated contents of the
265 label buffer give the survey that the leg is in. Return leg from current
266 position to coordinates given, and update current position to coordinates
267 given.
268 </td>
269 <td class="version" rowspan="5">&ge;8</td>
270 </tr>
271 <tr>
272 <th>Flag (N &amp; 0x3f)</th>
273 <th>Meaning</th>
274 </tr>
275 <tr>
276 <td>0x01</td>
277 <td>Leg is above ground</td>
278 </tr>
279 <tr>
280 <td>0x02</td>
281 <td>Leg duplicates data in another leg (e.g. resurvey along a passage to
282 tie into a known station)</td>
283 </tr>
284 <tr>
285 <td>0x04</td>
286 <td>Leg is a splay shot in a chamber (radial shots from a central point)</td>
287 </tr>
288 <tr class="reserved">
289 <td>0x08</td>
290 <td colspan="2">Reserved</td>
291 </tr>
292 <tr class="reserved">
293 <td>0x10</td>
294 <td colspan="2">Reserved</td>
295 </tr>
296 <tr>
297 <td>0x20</td>
298 <td>No change to label (&lt;label&gt; omitted entirely)</td>
299 <td class="version">&ge;8</td>
300 </tr>
301 <tr>
302 <td class="code" rowspan="10">0x80 - 0xff</td>
303 <td class="type" rowspan="10">LABEL</td>
304 <td class="data" rowspan="10">&lt;label&gt; &lt;x&gt; &lt;y&gt; &lt;z&gt;</td>
305 <td colspan="2">
306 Modify the current label buffer according to &lt;label&gt; (see below for
307 details). The updated contents of the label buffer give the survey
308 station's full name.
309 </td>
310 <td class="version" rowspan="10">&ge;8</td>
311 </tr>
312 <tr>
313 <td colspan="2">
314 The station flags are encoded in the bottom 7 bits of the item code:</td>
315 </tr>
316 <tr>
317 <th>Flag (N &amp; 0x7f)</th>
318 <th>Meaning</th>
319 </tr>
320 <tr>
321 <td>0x01</td>
322 <td>Station is on leg above ground</td>
323 </tr>
324 <tr>
325 <td>0x02</td>
326 <td>Station is on an underground leg (both may be true at an entrance)</td>
327 </tr>
328 <tr>
329 <td>0x04</td>
330 <td>Station is marked as an entrance (with *entrance)</td>
331 </tr>
332 <tr>
333 <td>0x08</td>
334 <td>Station is exported (i.e. may be used as a connection point to other
335 surveys)</td>
336 </tr>
337 <tr>
338 <td>0x10</td>
339 <td>Station is a fixed point (control point)</td>
340 </tr>
341 <tr>
342 <td>0x20</td>
343 <td>Station is anonymous</td>
344 </tr>
345 <tr>
346 <td>0x40</td>
347 <td>Station is on the passage wall</td>
348 </tr>
349 </table>
351 <p>A &lt;label&gt; value in the tabel above encodes modifications to the
352 current label buffer, which consist of removing the last <i>D</i> bytes
353 from the buffer, and then appending the next <i>A</i> bytes from the file
354 to the buffer. <i>D</i> and <i>A</i> are encoded as follows:</p>
356 <ul>
357 <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>
358 <li>Otherwise (i.e. the first byte is zero):
359 <ul>
360 <li>Read a byte and:
361 <ul>
362 <li>If it is not 255 then <i>D</i> = <code>byte</code>
363 <li>Otherwise, <i>D</i> = 4 byte unsigned integer read from the file
364 </ul>
365 <li>Read a byte and:
366 <ul>
367 <li>If it is not 255 then <i>A</i> = <code>byte</code>
368 <li>Otherwise, <i>A</i> = 4 byte unsigned integer read from the file
369 </ul>
370 </ul>
371 </ul>
373 <H2>Item order</H2>
374 <ul>
375 <li>A continuous section of centreline is defined by a &lt;MOVE&gt; item, followed
376 by one or more &lt;LINE&gt; items.</li>
377 <li>&lt;LABEL&gt; items may appear anywhere in the file after the header,
378 including within a &lt;MOVE&gt;&lt;LINE&gt;... sequence.</li>
379 <li>Duplicate &lt;LABEL&gt; items are permitted provided they also have identical
380 coordinate values. (The same coordinate values may also be shared by any
381 number of different &lt;LABEL&gt; items).</li>
382 <li>Stations must be defined in a &lt;LABEL&gt; item <u>before</u> being
383 referenced (e.g. in &lt;XSECT&gt; items)</li>
384 </ul>
386 <P>Authors: Olly Betts and Mike McCombe, last updated: 2016-05-17</P>
387 </BODY></HTML>