/* blockstat.h Defines some structures and constants used by the blockstat subroutines and main programs. W H F Smith, 9 Jan 2007, version 1. */ struct BM_DATA_IN { int index; /* identifier for BM pixel */ int source_id; /* unique file number for the source of this point value */ short int z; /* a depth or elevation value, neg below sea level */ short int s; /* combined H and V uncertainty in this z value */ }; struct BM_DATA_OUT { int index; /* range from 0 up to 933 120 000 - 1 for srtm30 */ int id_min; /* source ID associated with minimum (deepest) z value */ int id_med; /* source ID associated with median value */ int id_max; /* source ID associated with maximum (shallowest) z value */ short int z_min; /* minimum (deepest) z value */ short int z_max; /* maximum (shallowest) z value */ short int z_mean; /* mean z value */ short int z_std; /* standard deviation of z values */ short int z_median; /* median z value in this block */ short int z_spread; /* inter-quartile range of z in this block */ }; struct BM_CSYS { /* Coordinate system info */ double radius; /* Used for Mercator img only */ double maxlat; /* Range of data mapped -maxlat < lat <= maxlat */ int img; /* True to use Mercator img, false for lon,lat (srtm30) */ int npd; /* # of pixels per degree (lon), that is, 30, 60, 120 */ int ntot; /* nx * ny. */ int nx; /* # of pixels in 360 degrees of lon */ int ny; /* # of pixels in (-maxlat, maxlat] */ int nyh; /* ny/2, used for Mercator img only. */ }; struct BM_ERR_PARAMS { double ha; double hb; double va; double vb; double smin; double ha2; double va2; double smin2; }; /* Definitions of macros for coordinate types: */ #define GTOPO30 1 #define IMG1M72 2 #define IMG1M81 3 #define IMG2M72 4 #define IMG2M81 5 /* Default values for horizontal and vertical sigma a and b. The error is computed as e = hypot(a, b*z), where z is depth. These assume the horizontal errors are given in meters. The vertical numbers below give half the error allowed by IHO S-44 (1998 edition) Order 3 Bathymetric Models; the IHO standard is a 95% confidence standard. SIG_H_A assumes excellent GPS navigation and SIG_H_B assumes a beam width of 200 m in 5 km of water. These numbers are probably too small. */ #define SIG_H_A 1.0 #define SIG_H_B 0.02 #define SIG_V_A 2.5 #define SIG_V_B 0.025 /* SIG_Z_MIN is used to set a minimum, positive uncertainty in depth if the computed uncertainty comes out too small. */ #define SIG_Z_MIN 1.0 /* NSX, NSY, NST are the X Y and Total dimensions of the one byte per pixel, global lat lon one arc minute file of seafloor slopes to use in converting horizontal uncertainties to vertical uncertainties. */ #define NSX 21600 #define NSY 10800 #define NST 233280000 int lonlat_from_k (int k, double *lon, double *lat, struct BM_CSYS *coords); int k_from_lonlat (double lon, double lat, struct BM_CSYS *coords); int init_coords (struct BM_CSYS *coords, int coord_type); void init_default_err_p (struct BM_ERR_PARAMS *err_p); int square_err_a (struct BM_ERR_PARAMS *err_p); FILE *get_next_fp (int stdin_is_list, int argc, char **argv, int *nargfiles, int *karg, FILE *fplist, FILE *lastfp); int load_slopes (FILE *fp, unsigned char *sfslope); void dat2bmdi (double x, double y, double z, double sh, double sv, int srcid, unsigned char *sfslope, struct BM_ERR_PARAMS *err_p, struct BM_CSYS *coords, struct BM_DATA_IN *bmdi); int process_cm_record (char *strbuf, unsigned char *sfslope, struct BM_ERR_PARAMS *err_p, struct BM_CSYS *coords, struct BM_DATA_IN *bmdi);