summaryrefslogtreecommitdiff
path: root/src/convertcoords.c
diff options
context:
space:
mode:
authorDirk Engling <erdgeist@erdgeist.org>2014-02-20 22:42:56 +0100
committerDirk Engling <erdgeist@erdgeist.org>2014-02-20 22:42:56 +0100
commit046857dfb88f05e6b310fe9ef07b9f2d3ac5922d (patch)
tree9ce854f9572168c3ec1fe6751276430fa4a79cd9 /src/convertcoords.c
parent64c85dfc1d3b546dd4b5f84168e9256817f3a741 (diff)
Restructure project, make names more clear
Diffstat (limited to 'src/convertcoords.c')
-rw-r--r--src/convertcoords.c40
1 files changed, 0 insertions, 40 deletions
diff --git a/src/convertcoords.c b/src/convertcoords.c
deleted file mode 100644
index 37d780a..0000000
--- a/src/convertcoords.c
+++ /dev/null
@@ -1,40 +0,0 @@
1#include <stdio.h>
2#include <stdlib.h>
3#include <math.h>
4int main(int argc, char *argv[])
5{
6 double x, y;
7 char buf[64];
8 int in;
9 while( fgets( buf, sizeof(buf), stdin ) )
10 {
11 if( sscanf( buf, "%lf %lf", &x, &y ) == 2 ) {
12 double R = 6365000;
13 double fe = 5200000;
14 double fn = 1200000;
15 double ph0 = 0.5235977; // 30deg
16 double ph1 = 0.7853980; // 45deg
17 double ph2 = 0.9599309; // 55deg
18 double l0 = 0.1745329; // 10deg
19
20 double xs = (x-fe)/R;
21 double ys = (y-fn)/R;
22 double ph0_s = 0.25*M_PI+0.5*ph0;
23 double ph1_s = 0.25*M_PI+0.5*ph1;
24 double ph2_s = 0.25*M_PI+0.5*ph2;
25
26 double n = log(cos(ph1)/cos(ph2))/log(tan(ph2_s)/tan(ph1_s));
27 double F = cos(ph1)*pow(tan(ph1_s),n)/n;
28 double r0 = F / pow(tan(ph0_s),n);
29 double r = sqrt(pow(xs,2)+pow(r0-ys,2));
30 double th = atan(xs/(r0-ys));
31
32 double lon = l0+th/n;
33 double lat = 2.0*atan(pow(F/r,1.0/n))-0.5*M_PI;
34
35 printf("%lf\t%lf\n", lat*180.0/M_PI, lon*180.0/M_PI);
36 } else
37 printf("\t\n");
38 }
39 return 0;
40}