"Initial commit to Gerrit"
[profile/ivi/gpsd.git] / test_geoid.c
1 /* test driver for the ECEF to WGS84 conversions in geoid.c
2  *
3  * This file is Copyright (c) 2010 by the GPSD project
4  * BSD terms apply: see the file COPYING in the distribution root for details. 
5  */
6
7 #include <sys/types.h>
8 #include <math.h>
9 #include <stdio.h>
10 #include <stdlib.h>
11
12 #include "gpsd.h"
13
14 int main(int argc, char **argv)
15 {
16     double lat, lon;
17
18     if (argc != 3) {
19         fprintf(stderr, "Usage: %s lat lon\n", argv[0]);
20         return 1;
21     }
22
23     lat = atof(argv[1]);
24     lon = atof(argv[2]);
25
26     if (lat > 90. || lat < -90.) {
27         fprintf(stderr, " -90 <= lat=%s(%.f) <= 90 ?\n", argv[1], lat);
28         return 1;
29     }
30
31     if (lon > 180. || lat < -180.) {
32         fprintf(stderr, " -180 <= lon=%s(%.f) <= 180 ?\n", argv[2], lon);
33         return 1;
34     }
35
36     printf(" lat= %f lon= %f geoid correction= %f\n",
37            lat, lon, wgs84_separation(lat, lon));
38
39     return 0;
40 }