compass import into cavern
Simeon Warner
simeon at cs.cornell.edu
Wed Oct 13 23:04:01 BST 2004
Olly,
I asked Larry Fish and indeed both -999.0 and 999.0 values mean 'no value'
in Compass. Compass itself uses -999.0, Karst uses 999.0 and this value is
also accepted by Compass.
I followed your suggestion and made additional cases for all the Compass
data types. It would be nice to localize the enum values to datain.c.
However, I don't know any way to cleanly extend an enum type in c so I put
them in cavern.h along with CompassDATFlags.
I append diffs against the latest cvs for 1.1.1. I've tested this with the
Lechuguilla data set but don't have other Compass data sets to play with.
Cheers,
Simeon
Index: cavern.h
===================================================================
RCS file: /usr/data/cvs/survex/src/cavern.h,v
retrieving revision 1.64.2.5
diff -p -r1.64.2.5 cavern.h
*** cavern.h 29 Jul 2003 15:14:22 -0000 1.64.2.5
--- cavern.h 13 Oct 2004 21:53:43 -0000
*************** typedef enum {
*** 145,152 ****
End = 0, Tape, Comp, Clino, BackComp, BackClino,
FrDepth, ToDepth, Dx, Dy, Dz, FrCount, ToCount,
/* Up to here are readings used in datain.c */
Fr, To, Station, Depth, DepthChange, Count, Dir,
- CompassDATFlags,
Newline, IgnoreAllAndNewLine, Ignore, IgnoreAll
} reading;
/* Tape Comp Clino BackComp BackClino FrDepth ToDepth Dx Dy Dz FrCount ToCount */
--- 145,153 ----
End = 0, Tape, Comp, Clino, BackComp, BackClino,
FrDepth, ToDepth, Dx, Dy, Dz, FrCount, ToCount,
/* Up to here are readings used in datain.c */
+ CompassDATComp, CompassDATClino,
+ CompassDATBackComp, CompassDATBackClino, CompassDATFlags,
Fr, To, Station, Depth, DepthChange, Count, Dir,
Newline, IgnoreAllAndNewLine, Ignore, IgnoreAll
} reading;
/* Tape Comp Clino BackComp BackClino FrDepth ToDepth Dx Dy Dz FrCount ToCount */
Index: datain.c
===================================================================
RCS file: /usr/data/cvs/survex/src/datain.c,v
retrieving revision 1.92.2.10
diff -p -r1.92.2.10 datain.c
*** datain.c 1 Oct 2004 19:58:51 -0000 1.92.2.10
--- datain.c 13 Oct 2004 21:53:43 -0000
***************
*** 42,47 ****
--- 42,51 ----
#define var(I) (pcs->Var[(I)])
+ /* true if x is not-a-number value in Compass (999.0 or -999.0) */
+ /* Compass uses 999.0 but understands Karst data which used -999.0 */
+ #define is_compass_NaN(x) ( fabs(fabs(x)-999.0) < EPSILON )
+
int ch;
typedef enum {
*************** data_file(const char *pth, const char *f
*** 449,460 ****
if (fmt == FMT_DAT) {
while (!feof(file.fh) && !ferror(file.fh)) {
static reading compass_order[] = {
! Fr, To, Tape, Comp, Clino, Ignore, Ignore, Ignore, Ignore,
CompassDATFlags, IgnoreAll
};
static reading compass_order_backsights[] = {
! Fr, To, Tape, Comp, Clino, Ignore, Ignore, Ignore, Ignore,
! BackComp, BackClino,
CompassDATFlags, IgnoreAll
};
/* <Cave name> */
--- 453,466 ----
if (fmt == FMT_DAT) {
while (!feof(file.fh) && !ferror(file.fh)) {
static reading compass_order[] = {
! Fr, To, Tape, CompassDATComp, CompassDATClino,
! Ignore, Ignore, Ignore, Ignore, /*LRUD*/
CompassDATFlags, IgnoreAll
};
static reading compass_order_backsights[] = {
! Fr, To, Tape, CompassDATComp, CompassDATClino,
! Ignore, Ignore, Ignore, Ignore, /*LRUD*/
! CompassDATBackComp, CompassDATBackClino,
CompassDATFlags, IgnoreAll
};
/* <Cave name> */
*************** data_normal(void)
*** 1536,1541 ****
--- 1542,1577 ----
fDepthChange = fTrue;
VAL(FrDepth) = 0;
read_reading(ToDepth, fFalse);
+ break;
+ case CompassDATComp:
+ read_bearing_or_omit(Comp);
+ if (is_compass_NaN(VAL(Comp))) VAL(Comp) = HUGE_REAL;
+ break;
+ case CompassDATBackComp:
+ read_bearing_or_omit(BackComp);
+ if (is_compass_NaN(VAL(BackComp))) VAL(BackComp) = HUGE_REAL;
+ break;
+ case CompassDATClino:
+ read_reading(Clino, fTrue);
+ if (is_compass_NaN(VAL(Clino))) {
+ VAL(Clino) = HUGE_REAL;
+ ctype = CTYPE_OMIT;
+ } else if (VAL(Clino) == HUGE_REAL) {
+ compile_error_token(/*Expecting numeric field, found `%s'*/9);
+ process_eol();
+ return 0;
+ } else ctype = CTYPE_READING;
+ break;
+ case CompassDATBackClino:
+ read_reading(BackClino, fTrue);
+ if (is_compass_NaN(VAL(BackClino))) {
+ VAL(BackClino) = HUGE_REAL;
+ backctype = CTYPE_OMIT;
+ } else if (VAL(BackClino) == HUGE_REAL) {
+ compile_error_token(/*Expecting numeric field, found `%s'*/9);
+ process_eol();
+ return 0;
+ } else backctype = CTYPE_READING;
break;
case CompassDATFlags:
if (ch == '#') {
More information about the Survex
mailing list