Building cavestats

David Loeffler d.loeffler.01 at cantab.net
Thu Feb 3 16:17:38 GMT 2011


On 3 February 2011 09:12, Wookey <wookey at wookware.org> wrote:
> The CUCC website uses a C program called cavestats, which is a hacked
> version of 3dtopos, written by dave loeffler I think.
>
> It's attached.

I plead guilty to the crime of writing this disgusting little hack,
m'lud. May I be permitted to explain to the court the extenuating
circumstances? :-)

As the CUCC contingent here know well, for every cave we discover on
the CUCC Austria trips, we have to fill in a form to get it registered
in the Austrian government's official register of caves. There are
some boxes on the form for various statistics, including surveyed
length, depth, and *horizontal extent*.

Cavern outputs length and depth at the end of its run, and also
reports the N-S and E-W range of the cave, but it doesn't calculate
horizontal extent. If I were a lazier man, I might have simply taken
the max of the N-S and E-W extents and relaxed in the knowledge that I
was never going to be more than 41% wrong; but I decided to do the
thing properly: I wrote some code that, given a cloud of points in 2-d
space, finds the pair with the greatest distance apart. Since I knew
absolutely zilch about C, I chose to base my program around the
existing code of 3dtopos which dealt with reading in a .3d file.

I later found that this had another handy application. One page on the
CUCC website is a massive table listing the length and depth of all
200+ caves in our area; and it was much faster to generate this by
using cavestats on the single .3d file that contained all our data,
rather than running cavern 200+ times to get length and depth of each
cave. So this is why the CUCC website (as currently set up) uses
cavestats.

Were I to be writing cavestats now, I'd probably write a freestanding
program that is designed to have the output of 3dtopos or dump3d piped
into it, rather than one that reads .3d files itself; this then
wouldn't need to be compiled using Survex's header files and so on.
Isn't hindsight great?

David



More information about the Survex mailing list