File: gridutils.c

package info (click to toggle)
gpstrans 0.34-6
  • links: PTS
  • area: main
  • in suites: potato
  • size: 476 kB
  • ctags: 348
  • sloc: ansic: 3,463; makefile: 97
file content (39 lines) | stat: -rw-r--r-- 2,231 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
/****************************************************************************/
/*                                                                          */
/* ./grid/gridutils.c   -   Calculate datum variables                       */
/*                                                                          */
/* This file is part of gpstrans - a program to communicate with garmin gps */
/* Parts are taken from John F. Waers (jfwaers@csn.net) program MacGPS.     */
/*                                                                          */
/*                                                                          */
/*    Copyright (c) 1995 by Carsten Tschach (tschach@zedat.fu-berlin.de)    */
/*                                                                          */
/* Permission  to use, copy,  modify, and distribute  this software and its */
/* documentation for non-commercial purpose, is hereby granted without fee, */
/* providing that the  copyright notice  appear in all copies and that both */
/* the  copyright notice and  this permission  notice appear in  supporting */
/* documentation.  I make no representations about  the suitability of this */
/* software  for any  purpose.  It is  provides "as is" without  express or */
/* implid warranty.                                                         */
/*                                                                          */
/****************************************************************************/
#include "defs.h"
#include "Garmin.h"
#include "Prefs.h"


/****************************************************************************/
/* Calculate datum parameters.                                              */
/****************************************************************************/
void datumParams(short datum, double *a, double *es)
{
  extern struct DATUM     const gDatum[];
  extern struct ELLIPSOID const gEllipsoid[];
  extern struct PREFS           gPrefs;
  
  double f = 1.0 / gEllipsoid[gDatum[datum].ellipsoid].invf;   /* flattening */
    
  *es = 2 * f - f*f;                                       /* eccentricity^2 */
  *a  = gEllipsoid[gDatum[datum].ellipsoid].a;             /* semimajor axis */
}