Geo Stars Library  0.9.3
Geodetic and Astrometry library
geoEllips.c File Reference

This file contains geo library location setup and initialization of ellipsoid values. There are 23 ellipsoids to choose from, of which the WGS 84 ellipsoid is the default ellipsoid. More...

#include <stdio.h>
#include <math.h>
#include <string.h>
#include <time.h>
#include "geoStars.h"
Include dependency graph for geoEllips.c:

Go to the source code of this file.

Functions

int geoInitLocation (GEO_LOCATION *l, double lat, double lon, double hgt, int datum, char *name)
 This routine needs to be called when a site (or location) is initialized. Several of the routines use the information in the structure that this routine fills. More...
 
void geoSetTimeZone (GEO_LOCATION *l, double tz, int dst)
 
void geoGetEllipsoid (double *a, double *b, double *e2, double *ee2, double *f, int datum)
 This routine computes essential datum values from basic parameters obtained from the ellips structure. More...
 

Variables

GEO_ELLIPSOID ellips []
 This structure array contains the all of the ellipsoids used in this library. More...
 

Detailed Description

This file contains geo library location setup and initialization of ellipsoid values. There are 23 ellipsoids to choose from, of which the WGS 84 ellipsoid is the default ellipsoid.

Definition in file geoEllips.c.

Function Documentation

void geoGetEllipsoid ( double *  a,
double *  b,
double *  e2,
double *  ee2,
double *  f,
int  datum 
)

This routine computes essential datum values from basic parameters obtained from the ellips structure.

Parameters
double*a : Major axis ( Meters )
double*b : Minor axis ( Meters )
double*e2 : Eccentricity
double*ee2 : Eccentricity prime
double*f : Flattening
intdatum : Datum to use
Returns
nothing

Definition at line 189 of file geoEllips.c.

References GEO_ELLIPSOID::a, GEO_B, GEO_E2, GEO_E2P, and GEO_FL.

Referenced by geoEfg2Llh(), geoEfg2Llh_aa(), geoEfg2Llh_borkowski(), geoEfg2Llh_bowring(), geoEfg2Llh_heikkinen(), geoEfg2Llh_hm(), geoEfg2Llh_toms(), geoEfg2Llh_torge(), geoEfg2Llh_vermeille(), geoInitLocation(), and geoLlh2Efg().

190 {
191  /* - Major Axis. */
192  *a = ellips[datum].a;
193 
194  /* - Earth Flattening. */
195  *f = GEO_FL(ellips[datum].f1);
196 
197  /* - Minor axis value. */
198  *b = GEO_B(ellips[datum].a, (ellips[datum].f1));
199 
200  /* - Eccentricity squared. */
201  *e2 = GEO_E2(ellips[datum].a, (ellips[datum].f1));
202 
203  /* - Eccentricity squared prime. */
204  *ee2 = GEO_E2P(ellips[datum].a, (ellips[datum].f1));
205 
206 
207 #ifdef GEO_DEBUG
208  printf("DEBUG: a=%f, b=%f, f=%f, e2=%f, e2p=%f \n",*a, *b, *f, *e2, *ee2);
209 #endif
210 }
int geoInitLocation ( GEO_LOCATION l,
double  lat,
double  lon,
double  hgt,
int  datum,
char *  name 
)

This routine needs to be called when a site (or location) is initialized. Several of the routines use the information in the structure that this routine fills.

Parameters
GEO_LOCATION*l
doublelat
doublelon
doublehgt
intdatum
char*name //Name of the site location
Return values
GEO_OKon success
GEO_ERRORon error

Definition at line 96 of file geoEllips.c.

References GEO_DATUM::a, GEO_DATUM::b, GEO_LOCATION::clat, GEO_LOCATION::clon, GEO_LOCATION::clonclat, GEO_LOCATION::clonslat, GEO_LOCATION::datum, GEO_DATUM::datum_num, DEG_TO_RAD, GEO_LOCATION::e, GEO_DATUM::e2, GEO_DATUM::ee2, GEO_LOCATION::efg, GEO_LOCATION::f, GEO_DATUM::flat, GEO_LOCATION::g, GEO_DATUM_MAX, GEO_E, GEO_ERROR, GEO_F, GEO_G, GEO_OK, geoGetEllipsoid(), geoMagFillDec(), GEO_LOCATION::hgt, GEO_LOCATION::lat, GEO_LOCATION::lon, GEO_DATUM::m1e2, GEO_LOCATION::name, GEO_LOCATION::rlat, GEO_LOCATION::rlon, GEO_LOCATION::slat, GEO_LOCATION::slon, GEO_LOCATION::slonclat, GEO_LOCATION::slonslat, GEO_LOCATION::timezone, and GEO_LOCATION::tlat.

Referenced by geoLlh2DiffX(), geoLlh2DiffY(), geoLlh2DiffZ(), geoLlh2E(), geoLlh2F(), geoLlh2G(), geoSunNowAz(), and geoSunNowEl().

97 {
98  double N,a,e2,ee2, b, flat,Nh;
99  double dec;
100  // struct tm *newtime;
101  // time_t aclock;
102 
103 
104  /* Validate and get datum values */
105  if(datum > GEO_DATUM_MAX) return(GEO_ERROR);
106  geoGetEllipsoid(&a,&b,&e2,&ee2,&flat,datum); /* Calls to read in "to" ellipsoid data */
107 
108  /* Initialize ellipsoid values in the location descriptor */
109  l->datum.a = a;
110  l->datum.b = b;
111  l->datum.e2 = e2;
112  l->datum.flat = flat ;
113  l->datum.ee2 = ee2;
114  l->datum.m1e2 = 1.0 - e2;
115 
116 
117  /* Initialize lat/lon values */
118  if(lon>180.0)lon=lon-360.0; // normalize to -180 to +180
119  l->lat = lat;
120  l->lon = lon;
121  l->hgt = hgt;
122 
123  l->rlat = lat * DEG_TO_RAD; /* make radians */
124  l->rlon = lon * DEG_TO_RAD;
125 
126  /* Precompute sin/cos values */
127 #ifdef HAVE_SINCOS
128  sincos(l->rlat,&l->slat,&l->clat);
129  sincos(l->rlon,&l->slon,&l->clon);
130 #else
131  l->slat = sin(l->rlat);
132  l->slon = sin(l->rlon);
133  l->clat = cos(l->rlat);
134  l->clon = cos(l->rlon);
135 #endif
136  l->tlat = tan(l->rlat);
137  l->clonclat = l->clon * l->clat;
138  l->slonslat = l->slon * l->slat;
139  l->clonslat = l->clon * l->slat;
140  l->slonclat = l->slon * l->clat;
141 
142  /* Compute geocentric coordinates */
143 
144  /* Compute the radius of curvature */
145  N = a / (sqrt(1.0 - e2 * pow(l->slat,2.0)));
146 
147  /* Compute the EFG(XYZ) coordinates (earth centered) */
148  Nh = N + hgt;
149  l->e = Nh * l->clonclat; //l->clat * l->clon;
150  l->f = Nh * l->slonclat; //l->clat * l->slon;
151  l->g = (N * (l->datum.m1e2) + hgt) * l->slat;
152  l->efg[GEO_E] = l->e;
153  l->efg[GEO_F] = l->f;
154  l->efg[GEO_G] = l->g;
155 
156  /* Compute the Magnetic Declination */
157  geoMagFillDec(l,&dec);
158 
159  /* Time Zone */
160  l->timezone = 0.0; //use geoSetTimeZone to set this value
161 
162  /* Save datum and site info */
163  l->datum.datum_num = datum;
164  strcpy(l->name, name);
165 
166  return(GEO_OK);
167 }

Here is the call graph for this function:

void geoSetTimeZone ( GEO_LOCATION l,
double  tz,
int  dst 
)

Definition at line 169 of file geoEllips.c.

References GEO_LOCATION::dst, and GEO_LOCATION::timezone.

170 {
171  l->timezone = tz;
172  l->dst = dst;
173 }

Variable Documentation

GEO_ELLIPSOID ellips[]
Initial value:
=
{
{ "Default Ellipsoid (WGS 1984) ","00", 6378137.0 ,298.257223563 },
{ "Airy 1830 ","AA", 6377563.396 ,299.3249646 },
{ "Australian National ","AN", 6378160.0 ,298.25 },
{ "Bessel 1841 ","BR", 6377397.155 ,299.1528128 },
{ "Bessel 1841 (Namibia) ","BN", 6377483.865 ,299.1528128 },
{ "Clarke 1866 ","CC", 6378206.4 ,294.9786982 },
{ "Clarke 1880 ","CD", 6378249.145 ,293.465 },
{ "Everest (Brunei, E. Malaysia) ","EB", 6377298.556 ,300.8017 },
{ "Everest 1830 ","EA", 6377276.345 ,300.8017 },
{ "Everest 1956 (India and Nepal) ","EC", 6377301.243 ,300.8017 },
{ "Everest (Pakistan) ","EF", 6377309.613 ,300.8017 },
{ "Everest 1948 (W. Malaysia and Singapore)","EE", 6377304.063 ,300.8017 },
{ "Everest 1969 (W. Malaysia) ","ED", 6377295.664 ,300.8017 },
{ "Geodetic Reference System 1980 ","RF", 6378137.0 ,298.257222101 },
{ "Helmert 1906 ","HE", 6378200.0 ,298.3 },
{ "Hough 1960 ","HO", 6378270.0 ,297.0 },
{ "Indonesian 1974 ","ID", 6378160.0 ,298.247 },
{ "International 1924 ","IN", 6378388.0 ,297.0 },
{ "Krassovsky 1940 ","KA", 6378245.0 ,298.3 },
{ "Modified Airy ","AM", 6377340.189 ,299.3249646 },
{ "Modified Fischer 1960 ","FA", 6378155.0 ,298.3 },
{ "South American 1969 ","SA", 6378160.0 ,298.25 },
{ "WGS 1972 ","WD", 6378135.0 ,298.26 },
{ "WGS 1984 ","WE", 6378137.0 ,298.257223563 }
}

This structure array contains the all of the ellipsoids used in this library.

Definition at line 46 of file geoEllips.c.

Referenced by geomg1().