#include "common.h"  /* PROTOTYPE_ALLOWED */

typedef struct
{
   double lon, lat;
} LONLAT_TYPE;

typedef struct
{
   double min, max;
} RANGE_TYPE;

typedef struct
{
   double x, y;
} XY_TYPE;

#define EPSILON 0.00001  /* tolerance for testing equality between map coords. */
#define WATER_BOUNDARY -8888.00  /* marks end of coordinates for lakes */
#define LAND_BOUNDARY  -9999.00  /* marks end of coordinates for land areas */
#define TOP            0
#define BOTTOM         1
#define LEFT           2
#define RIGHT          3
#define TOP_RIGHT      4
#define TOP_LEFT       5
#define BOTTOM_RIGHT   6
#define BOTTOM_LEFT    7
#define HORIZONTAL     8
#define VERTICAL       9

/* #define LatToIn(yy)  (( (yy) - origin_d.y) / DegPerInch.y)
#define LonToIn(xx)  (( (xx) - origin_d.x) / DegPerInch.x)  */
#define ExtendToAxis(lon) (fabs((lon)-lon_range.max) < fabs((lon)-lon_range.min) ? lon_range.max : lon_range.min)
#define equal(x, y) (fabs((x) - (y)) < EPSILON ? 1 : 0)
#define in_range(ll) (ll.lon >= lon_range.min && ll.lon <= lon_range.max && \
   ll.lat >= lat_range.min && ll.lat <= lat_range.max)

#if PROTOTYPE_ALLOWED
void drawmap(char *mapfile, FILE *fpps, RANGE_TYPE lon_range, RANGE_TYPE lat_range,
   double shading);
void connect(FILE *fpps, LONLAT_TYPE from, LONLAT_TYPE to, RANGE_TYPE lon_range,
   RANGE_TYPE lat_range, char delimiter);
int axis_crossed(LONLAT_TYPE exit, LONLAT_TYPE reentry, RANGE_TYPE lon_range, RANGE_TYPE lat_range);
int push(LONLAT_TYPE lonlat);
LONLAT_TYPE *pop(void);
#else
void drawmap();
void connect();
int axis_crossed();
int push();
LONLAT_TYPE *pop();
#endif

