00001
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035 #ifndef _COORDINATES_H_
00036 #define _COORDINATES_H_
00037
00038 #include <string.h>
00039 #include "oq.h"
00040
00041
00042 class Coordinate {
00043 public:
00044 signed int degrees;
00045 unsigned int minutes;
00046 double seconds;
00047
00048 Coordinate() { degrees = 0; minutes = 0; seconds = 0; };
00049 };
00050
00051
00052 class Coordinates {
00053 char _ellipsoid[MAX_NAME];
00054 double _geoid_diff;
00055
00056 static const double _K_ZERO = 0.9996;
00057
00058 int _reference_ellipsoid_index(const char *name);
00059 double _rad_distance(double lat1, double lon1,
00060 double lat2, double lon2);
00061
00062 public:
00063 static const unsigned int _GLOBAL_ELLIPSOIDS = 30;
00064
00065 Coordinate latitude;
00066 Coordinate longitude;
00067
00068 double lat;
00069 double lon;
00070 double altitude;
00071
00072 Coordinates() {
00073 strcpy(_ellipsoid, "WGS 84");
00074 _geoid_diff = 0.0;
00075 lat = lon = altitude = 0;
00076 };
00077 Coordinates(double lt, double ln, double alt) {
00078 strcpy(_ellipsoid, "WGS 84");
00079 _geoid_diff = 0.0;
00080 lat = lt; lon = ln; altitude = alt;
00081 };
00082 Coordinates(const Coordinates *c) {
00083 strcpy(_ellipsoid, "WGS 84");
00084 _geoid_diff = 0.0;
00085 latitude = c->latitude;
00086 longitude = c->longitude;
00087 altitude = c->altitude;
00088 };
00089
00090 char *get_ellipsoid() { return _ellipsoid; };
00091 double get_geoid_diff() { return _geoid_diff; };
00092 void set_ellipsoid(char *type);
00093 int list_reference_ellipsoids(char *names[], unsigned int *len);
00094
00095 void coords2meters(double lat, double lon, double *x, double *y);
00096 void meters2coords(double x, double y, double *lat, double *lon);
00097 double coord_distance(double lat1, double lon1,
00098 double lat2, double lon2);
00099 };
00100
00101
00102 static const struct {
00103 char *name;
00104 double equatorial_radius;
00105 double inverse_flattening;
00106 } reference_ellipsoids[Coordinates::_GLOBAL_ELLIPSOIDS] =
00107 {
00108 {"Airy 1830", 6377563.396, 299.3249646},
00109 {"Australian National 1966", 6378160, 298.25},
00110 {"Bessel 1841", 6377397.155, 299.1528128},
00111 {"Bessel Namibia 1841", 6377483.865, 299.1528128},
00112 {"Clarke 1866", 6378206.4, 294.9786982},
00113 {"Clarke 1880", 6378249.145, 293.465},
00114 {"Everest 1830", 6377276.345, 300.801697979},
00115 {"Fischer 1960", 6378166.0, 298.3},
00116 {"Fischer 1968", 6378150.0, 298.3},
00117 {"GRS 67", 6378160.0, 298.247167427},
00118 {"GRS 80", 6378137.0, 298.257222101},
00119 {"Hayford 1910", 6378388.0, 297.0},
00120 {"Helmert 1906", 6378200.0, 298.3},
00121 {"Hough", 6378270.0, 297.0},
00122 {"IERS 1989", 6378136.0, 298.257},
00123 {"International 1924", 6378388.0, 297.0},
00124 {"Krassovsky 1940", 6378245.0, 298.3},
00125 {"Mercury 1960", 6378166.0, 298.3},
00126 {"Modified Airy", 6377340.189, 299.3249646},
00127 {"Modified Everest", 6377304.063, 300.801699969},
00128 {"Modified Fischer 1960", 6378155.0, 298.3},
00129 {"Modified Mercury 1968", 6378150.0, 298.3},
00130 {"NAD 27", 6378206.4, 294.978698208},
00131 {"NAD 83", 6378137.0, 298.257024899},
00132 {"New International 1967", 6378157.5, 298.24961539},
00133 {"South American 1969", 6378160.0, 298.25},
00134 {"WGS 60", 6378165.0, 298.3},
00135 {"WGS 66", 6378145.0, 298.25},
00136 {"WGS 72", 6378135.0, 298.26},
00137 {"WGS 84", 6378137, 298.257223563}
00138 };
00139
00140
00141
00142
00143
00144
00145
00146
00147
00148
00149
00150 #endif // _COORDINATES_H_