C library for Geodesics
1.50.1
planimeter.c
Go to the documentation of this file.
1
/**
2
* @file planimeter.c
3
* @brief A test program for geod_polygon_compute()
4
**********************************************************************/
5
6
#include <stdio.h>
7
#include "
geodesic.h
"
8
9
#if defined(_MSC_VER)
10
/* Squelch warnings about scanf */
11
# pragma warning (disable: 4996)
12
#endif
13
14
/**
15
* A simple program to compute the area of a geodesic polygon.
16
*
17
* This program reads in lines with lat, lon for each vertex
18
* of a polygon. At the end of input, the program prints the number of
19
* vertices, the perimeter of the polygon and its area (for the WGS84
20
* ellipsoid).
21
**********************************************************************/
22
23
int
main
() {
24
double
a
= 6378137,
f
= 1/298.257223563;
/* WGS84 */
25
double
lat, lon, A, P;
26
int
n;
27
struct
geod_geodesic
g;
28
struct
geod_polygon
p;
29
geod_init
(&g, a, f);
30
geod_polygon_init
(&p, 0);
31
32
while
(scanf(
"%lf %lf"
, &
lat
, &
lon
) == 2)
33
geod_polygon_addpoint
(&g, &p,
lat
,
lon
);
34
n =
geod_polygon_compute
(&g, &p, 0, 1, &A, &P);
35
printf(
"%d %.8f %.3f\n"
, n, P, A);
36
return
0;
37
}
geod_polygon_compute
unsigned GEOD_DLL geod_polygon_compute(const struct geod_geodesic *g, const struct geod_polygon *p, int reverse, int sign, double *pA, double *pP)
geod_geodesic::f
double f
Definition:
geodesic.h:184
geodesic.h
API for the geodesic routines in C.
geod_polygon_init
void GEOD_DLL geod_polygon_init(struct geod_polygon *p, int polylinep)
geod_geodesic::a
double a
Definition:
geodesic.h:183
geod_geodesic
Definition:
geodesic.h:182
main
int main()
Definition:
planimeter.c:23
geod_polygon::lon
double lon
Definition:
geodesic.h:222
geod_polygon::lat
double lat
Definition:
geodesic.h:221
geod_polygon_addpoint
void GEOD_DLL geod_polygon_addpoint(const struct geod_geodesic *g, struct geod_polygon *p, double lat, double lon)
geod_polygon
Definition:
geodesic.h:220
geod_init
void GEOD_DLL geod_init(struct geod_geodesic *g, double a, double f)
Generated by
1.8.18