X-Git-Url: http://pileus.org/git/?a=blobdiff_plain;f=src%2Fgis-util.h;h=1b03f2fa578ff1c314b8f6d9886c1a98dbe56d21;hb=6a532537b8bc6a802fd058486a02a0d72b6933f7;hp=234bb16b84f091dd4a365774adb88aa5a3fdc242;hpb=b87064909e6d20e1ee2995adae0c1ce5cb692d7e;p=grits diff --git a/src/gis-util.h b/src/gis-util.h index 234bb16..1b03f2f 100644 --- a/src/gis-util.h +++ b/src/gis-util.h @@ -20,62 +20,173 @@ #include +/** + * EARTH_R: + * + * Radius of the earth + */ #define EARTH_R (6371000) + +/** + * EARTH_C: + * + * Circumference of the earth at the equator + */ #define EARTH_C (2*G_PI*EARTH_R) + +/** + * NORTH: + * + * Latitude at the north poll + */ #define NORTH 90 + +/** + * SOUTH: + * + * Latitude at the south poll + */ #define SOUTH -90 + +/** + * EAST: + * + * Eastern most longitude + */ #define EAST 180 + +/** + * WEST: + * + * Western most longitude + */ #define WEST -180 +/*************** + * Conversions * + ***************/ /** - * Terms - * ----- - * deg - Degrees - * rad - Radians, also radius - * m - Meters, for earth-based distances - * px - Pixels, for screen-based distances + * azim2lon: + * @azim: the azimuth in radians * - * height - Height, the distance above the geoid (ground) - * elev - Elevation, the distance above the spheroid - * rad - Radius, the distance from the center of the earth + * Convert azimuth to longitude * - * lat - Latitude, amount north-south, -90 (S) .. 90 (N) - * lon - Longitude, amount east-west, -180 (W) .. 180 (E) - * incl - Inclination, polar equiv of latitude, Pi .. 0 - * azim - Azimuth, polar equiv of longitude, -Pi .. Pi + * Returns: the longitude + */ +#define azim2lon(azim) ((azim)*180/G_PI) + +/** + * lon2azim: + * @lon: the longitude * - * x - 0° lon is positive - * y - 90° lon is positive - * z - North pole is positive + * Convert longitude to azimuth * - * llh - lat,lon,height - * lle - lat,lon,elev - * llr - lat,lon,rad - * pol - incl,azim,rad - * xyz - x,y,z + * Returns: the azimuth in radians */ +#define lon2azim(lon) ((lon)*G_PI/180) /** - * lat lon elev -> x y z - * lle2xyz: 0.0, 0.0, 0.0 -> 0.0, 0.0, 10.0 - * lle2xyz: 90.0, 0.0, 0.0 -> 0.0, 10.0, 0.0 - * lle2xyz: 0.0, 90.0, 0.0 -> 10.0, 0.0, 0.0 + * incl2lat: + * @incl: the inclination in radians * - * x y z -> lat lon elev - * xyz2lle: 10.0, 0.0, 0.0 -> 0.0, 90.0, 0.0 - * xyz2lle: 0.0, 10.0, 0.0 -> 90.0, 0.0, 0.0 - * xyz2lle: 0.0, 0.0, 10.0 -> 0.0, 0.0, 0.0 + * Convert inclination to latitude + * + * Returns: the latitude */ - #define incl2lat(incl) (90-(incl)*180/G_PI) + +/** + * lat2incl: + * @lat: the latitude + * + * Convert latitude to inclination + * + * Returns: the inclination in radians + */ #define lat2incl(lat) ((90-(lat))*G_PI/180) + +/** + * rad2elev: + * @rad: the radius in meters + * + * Convert radius to elevation + * + * Returns: the elevation in meters above the earth surface + */ #define rad2elev(rad) ((rad)-EARTH_R) + +/** + * elev2rad: + * @elev: the elevation in meters above the earth surface + * + * Convert elevation to radius + * + * Returns: the radius in meters + */ #define elev2rad(elev) ((elev)+EARTH_R) +/** + * deg2rad: + * @deg: the angle in degrees + * + * Convert degrees to radians + * + * Returns: the angle in radians + */ #define deg2rad(deg) (((deg)*G_PI)/180.0) + +/** + * rad2deg: + * @rad: the angle in radians + * + * Convert radians to degrees + * + * Returns: the angle in degrees + */ #define rad2deg(rad) (((rad)*180.0)/G_PI) + +/************* + * Datatypes * + *************/ + +/* GisPoint */ +typedef struct _GisPoint GisPoint; +struct _GisPoint { + gdouble lat, lon, elev; +}; + +void gis_point_set_lle(GisPoint *point, + gdouble lat, gdouble lon, gdouble elev); + +/* GisBBox */ +typedef struct _GisBBox GisBBox; +struct _GisBBox { + gdouble n, s, e, w; +}; + +void gis_bbox_set_bounds(GisBBox *bbox, + gdouble n, gdouble s, gdouble e, gdouble w); + + +/******** + * Misc * + ********/ +/** + * FOV_DIST: + * + * Used by GisOpenGL to set up the drawing window + */ #define FOV_DIST 2000.0 + +/** + * MPPX: + * @dist: the distance between the eye and the point in question + * + * Get the resolution that a point would be drawn at on the screen + * + * Returns: the resolution in meters per pixel + */ #define MPPX(dist) (4*dist/FOV_DIST) void lle2xyz(gdouble lat, gdouble lon, gdouble elev,