home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: Science / Science.zip / gmt_os2.zip / src / gmt_shore.h < prev    next >
Encoding:
C/C++ Source or Header  |  1996-09-22  |  6.0 KB  |  163 lines

  1. /*--------------------------------------------------------------------
  2.  *    The GMT-system:    @(#)gmt_shore.h    3.4  26 Jun 1995
  3.  *
  4.  *    Copyright (c) 1991-1995 by P. Wessel and W. H. F. Smith
  5.  *    See README file for copying and redistribution conditions.
  6.  *--------------------------------------------------------------------*/
  7. #include "netcdf.h"
  8.  
  9. #define MAX_DELTA 65535    /* Largest value to store in a ushort, used as largest dx or dy in bin  */
  10. #define MAX_LEVEL    4
  11.  
  12. #define N_BLEVELS    3
  13. #define N_RLEVELS    10
  14.  
  15. typedef unsigned char uchar;
  16.  
  17. typedef unsigned short int ushort; /* Added by Allen Cogbill, 9/22/96  */
  18.  
  19. struct SHORE {
  20.  
  21.     /* Global variables that remain fixed for all bins */
  22.     
  23.     int nb;            /* Number of bins to use */
  24.     int *bins;        /* Array with the nb bin numbers to use */
  25.     double scale;        /* Multiplier to convert dx, dy back to dlon, dlat in degrees */
  26.     
  27.     /* Variables associated with the current bin */
  28.     
  29.     int ns;            /* Number of segments to use in current bin */
  30.     uchar node_level[4];
  31.     struct SHORE_SEGMENT *seg;    /* Array of these segments */
  32.     struct SIDE *side[4];        /* Has position & id for each side exit/entry */
  33.     int nside[4];            /* Number of entries per side, including corner */
  34.     int n_entries;
  35.     double bsize;            /* Size of square bins in degrees */
  36.     double lon_sw;            /* Longitude of SW corner */
  37.     double lat_sw;            /* Latitude of SW corner */
  38.     double lon_corner[4];        /* Longitudes of 4 corners (depends on direction) */
  39.     double lat_corner[4];        /* Latitudes of 4 corners (depends on direction) */
  40.  
  41.     /* Data variables associated with shoreline database */
  42.     
  43.     nclong bin_size;    /* Size of square bins in minutes */
  44.     nclong bin_nx;        /* Number of bins in 360 degrees of longitude */
  45.     nclong bin_ny;        /* Number of bins in 180 degrees of latitude */
  46.     nclong n_bin;        /* Number of bins present in the data set */
  47.     nclong n_seg;        /* Number of segments present in the data set */
  48.     nclong n_pt;        /* Number of points present in the data set */
  49.     
  50.     nclong *bin_firstseg;    /* Array with ids of first segment per bin */
  51.     short *bin_info;    /* Array with levels of all 4 nodes per bin */
  52.     short *bin_nseg;    /* Array with number of segments per bin */
  53.     
  54.     char units[80];        /* Units of lon/lat */
  55.     char title[80];        /* Title of data set */
  56.     char source[80];    /* Source of data set */
  57.  
  58.     /* Netcdf ID variables */
  59.     
  60.     int cdfid;        /* File id for coastbin file */
  61.     
  62.     int bin_size_id;    /* Id for variable bin_size */
  63.     int bin_nx_id;        /* Id for variable bin_nx */
  64.     int bin_ny_id;        /* Id for variable bin_ny */
  65.     int n_bin_id;        /* Id for variable n_bin */
  66.     int n_seg_id;        /* Id for variable n_seg */
  67.     int n_pt_id;        /* Id for variable n_pt */
  68.     int bin_firstseg_id;    /* Id for variable bin_firstseg */
  69.     int bin_info_id;    /* Id for variable bin_info */
  70.     int bin_nseg_id;    /* Id for variable bin_nseg */
  71.     
  72.     int seg_info_id;    /* Id for variable seg_info */
  73.     int seg_area_id;    /* Id for variable seg_area */
  74.     int seg_start_id;    /* Id for variable seg_start */
  75.     
  76.     int pt_dx_id;        /* Id for variable pt_dx */
  77.     int pt_dy_id;        /* Id for variable pt_dy */
  78.     
  79. };
  80.  
  81. struct SHORE_SEGMENT {
  82.     uchar level;    /* Level of polygon segment (1 i ocean/land, 2 = land/lake, 3 = lake/island, etc) */
  83.     uchar entry;    /* Side (0-3) the segment starts on, or 4 for closed segments */
  84.     uchar exit;    /* Side (0-3) the segment ends on, or 4 for closed segments */
  85.     ushort n;    /* Number of points in segment */
  86.     short *dx;    /* Array of scaled longitudes relative to SW corner */
  87.     short *dy;    /* Array of scaled latitudes relative to SW corner */
  88. };
  89.  
  90. struct SIDE {
  91.     ushort pos;    /* Position along side in 0-65535 range */
  92.     short id;    /* Local segment id */
  93. };
  94.  
  95. struct BR {    /* Structure for Borders and Rivers */
  96.  
  97.     /* Global variables that remain fixed for all bins */
  98.     
  99.     int nb;            /* Number of bins to use */
  100.     int *bins;        /* Array with the nb bin numbers to use */
  101.     double scale;        /* Multiplier to convert dx, dy back to dlon, dlat in degrees */
  102.     
  103.     /* Variables associated with the current bin */
  104.     
  105.     int ns;            /* Number of segments to use in current bin */
  106.     struct BR_SEGMENT *seg;    /* Array of these segments */
  107.     double lon_sw;            /* Longitude of SW corner */
  108.     double lat_sw;            /* Latitude of SW corner */
  109.     double bsize;            /* Size of square bins in degrees */
  110.  
  111.     /* Data variables associated with shoreline database */
  112.     
  113.     nclong bin_size;    /* Size of square bins in minutes */
  114.     nclong bin_nx;        /* Number of bins in 360 degrees of longitude */
  115.     nclong bin_ny;        /* Number of bins in 180 degrees of latitude */
  116.     nclong n_bin;        /* Number of bins present in the data set */
  117.     nclong n_seg;        /* Number of segments present in the data set */
  118.     nclong n_pt;        /* Number of points present in the data set */
  119.     
  120.     nclong *bin_firstseg;    /* Array with ids of first segment per bin */
  121.     short *bin_nseg;    /* Array with number of segments per bin */
  122.     
  123.     char units[80];        /* Units of lon/lat */
  124.     char title[80];        /* Title of data set */
  125.     char source[80];    /* Source of data set */
  126.  
  127.     /* Netcdf ID variables */
  128.     
  129.     int cdfid;        /* File id for coastbin file */
  130.     
  131.     int bin_size_id;    /* Id for variable bin_size */
  132.     int bin_nx_id;        /* Id for variable bin_nx */
  133.     int bin_ny_id;        /* Id for variable bin_ny */
  134.     int n_bin_id;        /* Id for variable n_bin */
  135.     int n_seg_id;        /* Id for variable n_seg */
  136.     int n_pt_id;        /* Id for variable n_pt */
  137.     int bin_firstseg_id;    /* Id for variable bin_firstseg */
  138.     int bin_nseg_id;    /* Id for variable bin_nseg */
  139.     
  140.     int seg_n_id;        /* Id for variable seg_n */
  141.     int seg_level_id;    /* Id for variable seg_level */
  142.     int seg_start_id;    /* Id for variable seg_start */
  143.     
  144.     int pt_dx_id;        /* Id for variable pt_dx */
  145.     int pt_dy_id;        /* Id for variable pt_dy */
  146.     
  147. };
  148.  
  149. struct BR_SEGMENT {
  150.     ushort n;    /* Number of points in segment */
  151.     ushort level;    /* Hierarchial level of segment */
  152.     short *dx;    /* Array of scaled longitudes relative to SW corner */
  153.     short *dy;    /* Array of scaled latitudes relative to SW corner */
  154. };
  155.  
  156. struct POL {
  157.     int n;
  158.     int interior;    /* TRUE if polygon is inside bin */
  159.     int level;
  160.     double *lon;
  161.     double *lat;
  162. };
  163.