|
From: <le...@pr...> - 2004-11-07 05:32:25
|
Update of /cvsroot/meshdb/src/geo/libgeo In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25015 Modified Files: Tag: leonard-dev ntv2.c Log Message: debugging & clearer conditional stmt Index: ntv2.c =================================================================== RCS file: /cvsroot/meshdb/src/geo/libgeo/ntv2.c,v retrieving revision 1.4 retrieving revision 1.4.2.1 diff -u -d -r1.4 -r1.4.2.1 --- ntv2.c 3 Nov 2004 11:54:02 -0000 1.4 +++ ntv2.c 7 Nov 2004 05:32:15 -0000 1.4.2.1 @@ -25,10 +25,12 @@ /* XXX - these currently assume little endian */ #if defined(__i386__) +/* For big endian (like i386) */ #define HOSTFLOAT(f) (f) #define HOSTINT(i) (i) #define HOSTDOUBLE(d) (d) #else +/* For little endian (like sparc) */ #define HOSTFLOAT(f) swap4f(f) #define HOSTINT(i) swap4i(i) #define HOSTDOUBLE(d) swap8d(d) @@ -368,18 +370,21 @@ if (g->sibling && lookup(nt, g->sibling, lat, lon, result) == 0) return 0; - if (lat < g->s_lat || lat > g->n_lat) - return -1; - if (lon < g->e_lon || lon > g->w_lon) + if (!( g->s_lat < lat && lat < g->n_lat && + g->e_lon < lon && lon < g->w_lon )) return -1; if (g->firstchild && lookup(nt, g->firstchild, lat, lon, result) == 0) return 0; + Vprintf("* (%f, %f) is in grid %.8s\n", lat, lon, g->name); + /* Calculate the node coordinates within the subgrid */ x = (lon - g->e_lon) / g->lon_inc; y = (lat - g->s_lat) / g->lat_inc; + Vprintf("* using virtual node (%f, %f)\n", x, y); + /* Determine which 4 nodes around the give point to use (may be same) */ xlo = (int)floorf(x); ylo = (int)floorf(y); @@ -390,6 +395,12 @@ c = &g->nodes[xlo + yhi * g->w]; d = &g->nodes[xhi + yhi * g->w]; + Vprintf("* first approx delta=(%f, %f) +-(%f,%f) rad\n", + HOSTFLOAT(a->lat_shift) * nt->gs_scale, + HOSTFLOAT(a->lon_shift) * nt->gs_scale, + HOSTFLOAT(a->lat_shift_acc) * nt->gs_scale, + HOSTFLOAT(a->lon_shift_acc) * nt->gs_scale); + /* Perform bilinear interpolation of the four nodes */ xo = x - xlo; yo = y - ylo; @@ -406,6 +417,12 @@ HOSTFLOAT(b->lon_shift_acc), HOSTFLOAT(c->lon_shift_acc), HOSTFLOAT(d->lon_shift_acc), xo, yo) * nt->gs_scale; + Vprintf("* result = shift:(%f, %f) acc:(%f, %f)\n", + result->lat_shift, + result->lon_shift, + result->lat_shift_acc, + result->lon_shift_acc); + return 0; } @@ -419,5 +436,6 @@ double lat, lon; /* longitude is positive east */ struct ntv2_shift *result; { + Vprintf("* looking for (%f, %f)\n", lat, -lon); return lookup(nt, nt->root, lat, -lon, result); } |