Skip to content

Commit

Permalink
2.6: rescale to sea level
Browse files Browse the repository at this point in the history
  • Loading branch information
zvezdochiot committed Nov 9, 2021
1 parent 0fa0357 commit 4f7d015
Show file tree
Hide file tree
Showing 8 changed files with 78 additions and 40 deletions.
13 changes: 8 additions & 5 deletions man/man1/geofindkey.1
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.TH "GeoFindKey" 1 2.5 "10 Oct 2021" "User Manual"
.TH "GeoFindKey" 1 2.6 "09 Nov 2021" "User Manual"

.SH NAME
geofindkey
Expand All @@ -12,10 +12,13 @@ geofindkey [option] input-file report-file
.SH OPTIONS
.TP
-d N
number of decimals in the result coordinates, default 4
number of decimals in the result coordinates, default=4
.TP
-r
rescale mode (bool, optional, default = false)
-m str
rescale mode {NORM,EQUAL,EARCH}, default=NORM
.TP
-r N.N
radius Earth, default=6370009.0
.TP
-h
help
Expand All @@ -36,7 +39,7 @@ input-file
report-file
(sample):
key:
(normal)
(NORM)
--0-----
82135.4073
47128.1437
Expand Down
2 changes: 1 addition & 1 deletion man/man1/geofindkey2p.1
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.TH "GeoFindKey2Pow" 1 2.5 "10 Oct 2021" "User Manual"
.TH "GeoFindKey2Pow" 1 2.6 "09 Nov 2021" "User Manual"

.SH NAME
geofindkey2p
Expand Down
2 changes: 1 addition & 1 deletion man/man1/geositer500.1
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.TH "GeoSIter500" 1 2.5 "10 Oct 2021" "User Manual"
.TH "GeoSIter500" 1 2.6 "09 Nov 2021" "User Manual"

.SH NAME
geositer500
Expand Down
2 changes: 1 addition & 1 deletion man/man1/geoszbtoyxh.1
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.TH "GeoSZBtoYXH" 1 2.5 "10 Oct 2021" "User Manual"
.TH "GeoSZBtoYXH" 1 2.6 "09 Nov 2021" "User Manual"

.SH NAME
geoszbtoyxh
Expand Down
70 changes: 52 additions & 18 deletions src/geofindkey.c
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/*
Name: geofindkey.c
OldName: findkey.c
Version: 2.5
Date: 2021-10-10
Version: 2.6
Date: 2021-11-09
Author: Игорь Белов (https://gis-lab.info/forum/memberlist.php?mode=viewprofile&u=10457)
Author: zvezdochiot (https://github.com/zvezdochiot)
Author: Zoltan Siki (https://github.com/zsiki)
Expand All @@ -22,7 +22,8 @@ input file doc/data.dat:
*
output file report.dat:
*
key(normal):
key:
(NORM)
--0-----
82135.4073
47128.1437
Expand All @@ -49,10 +50,14 @@ key(normal):
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <unistd.h>

#define PNAME "GeoFindKey"
#define PVERSION "2.5"
#define PVERSION "2.6"

#define defMScale "NORM"
#define defREarth 6370009.0

void geofindkeytitle()
{
Expand All @@ -64,7 +69,8 @@ void geofindkeyusage()
fprintf(stderr, "usage: geofindkey [option] input-file report-file\n");
fprintf(stderr, "options:\n");
fprintf(stderr, " -d N decimal after comma, default=4\n");
fprintf(stderr, " -r rescale mode (bool, optional, default = false)\n");
fprintf(stderr, " -m str rescale mode {NORM,EQUAL,EARCH}, default=NORM\n");
fprintf(stderr, " -r N.N radius Earth, default=6370009.0\n");
fprintf(stderr, " -h this help\n");
fprintf(stderr, "\n");
fprintf(stderr, "input-file(sample):\n");
Expand All @@ -79,7 +85,7 @@ void geofindkeyusage()
fprintf(stderr, "\n");
fprintf(stderr, "report-file(sample):\n");
fprintf(stderr, " key:\n");
fprintf(stderr, " (normal)\n");
fprintf(stderr, " (NORM)\n");
fprintf(stderr, " --0-----\n");
fprintf(stderr, " 82135.4073\n");
fprintf(stderr, " 47128.1437\n");
Expand All @@ -106,6 +112,17 @@ void geofindkeyusage()
fprintf(stderr, " 0.0269 0.0248 0.0115 0.0003672639 0.0292\n");
}

int IndexMScale(char* mscale)
{
if (!strcmp(mscale,"NORM"))
return 0;
if (!strcmp(mscale,"EQUAL"))
return 1;
if (!strcmp(mscale,"EARTH"))
return 2;
return 0;
}

int main(int argc, char *argv[])
{
char buf[1024], name[32], format5[128], format7[128], format13[128];
Expand All @@ -118,18 +135,24 @@ int main(int argc, char *argv[])
FILE *fp0, *fp1;

int opt;
char* mscale;
int decimals = 4; /* number of decimals in the calculated coordinates */
double RE = defREarth;
int frescale = 0;
mscale = defMScale;
int fhelp = 0;
while ((opt = getopt(argc, argv, "d:rh")) != -1)
while ((opt = getopt(argc, argv, "d:m:r:h")) != -1)
{
switch(opt)
{
case 'd':
decimals = atoi(optarg);
break;
case 'm':
mscale = optarg;
break;
case 'r':
frescale = 1;
RE = atof(optarg);
break;
case 'h':
fhelp = 1;
Expand Down Expand Up @@ -163,6 +186,9 @@ int main(int argc, char *argv[])
exit(EXIT_FAILURE);
}

frescale = IndexMScale(mscale);
if (frescale == 0) mscale = defMScale;

/* подсчитать сумму координат */
n = 0;
for (i = 0; i < 8; i++) {s[i] = 0.0;}
Expand Down Expand Up @@ -264,12 +290,25 @@ int main(int argc, char *argv[])
/* найти вторичные параметры */
scale = hypot(a[1][0], a[1][1]);
rotation = atan2(a[1][1], a[1][0]);
if (frescale > 0 && scale != 0.0)

if(frescale > 0)
{
a[1][0] /= scale;
a[1][1] /= scale;
a[1][2] = 1.0;
if (scale > 0.0)
{
a[1][0] /= scale;
a[1][1] /= scale;
}
a[1][2] = 1.0;
if(frescale > 1)
{
if (RE > 0.0)
{
a[1][0] *= (1.0 - yc[2] / RE);
a[1][1] *= (1.0 - yc[2] / RE);
}
}
}

a[0][0] = yc[0] - a[1][0] * xc[0] + a[1][1] * xc[1];
a[0][1] = yc[1] - a[1][1] * xc[0] - a[1][0] * xc[1];
a[0][2] = yc[2] - a[1][2] * xc[2];
Expand All @@ -281,12 +320,7 @@ int main(int argc, char *argv[])
exit(EXIT_FAILURE);
}
fprintf(fp1, "key:\n");
if (frescale > 0)
{
fprintf(fp1, "(rescale)\n");
} else {
fprintf(fp1, "(normal)\n");
}
fprintf(fp1, "(%s)\n", mscale);
fprintf(fp1, "--0-----\n");
fprintf(fp1, "%.4f\n", a[0][0]);
fprintf(fp1, "%.4f\n", a[0][1]);
Expand Down
6 changes: 3 additions & 3 deletions src/geofindkey2p.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
Name: geofindkey2p.c
Version: 2.5
Date: 2021-10-10
Version: 2.6
Date: 2021-11-09
Author: zvezdochiot (https://github.com/zvezdochiot)
*
build:
Expand Down Expand Up @@ -57,7 +57,7 @@ output file report.dat:
#include <unistd.h>

#define PNAME "GeoFindKey2Pow"
#define PVERSION "2.5"
#define PVERSION "2.6"

void geofindkey2ptitle()
{
Expand Down
12 changes: 6 additions & 6 deletions src/geositer500.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
Name: geositer500.c
Version: 2.5
Date: 2021-10-10
Version: 2.6
Date: 2021-11-09
Author: zvezdochiot (https://github.com/zvezdochiot)
Author: Zoltan Siki (https://github.com/zsiki)
*
Expand Down Expand Up @@ -50,12 +50,13 @@ OKD-12 3.8890 288.39138889 133.60805556
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <unistd.h>
#include <string.h>
#include <unistd.h>

#define PNAME "GeoSIter500"
#define PVERSION "2.5"
#define PVERSION "2.6"

#define defREarth 6370009.0
#define defUnits "DEG"

void geositer500title()
Expand Down Expand Up @@ -150,9 +151,8 @@ int main(int argc, char *argv[])
int np;
FILE *fp0, *fp1;

double RE = 6370009.0;

int opt;
double RE = defREarth;
int decimals = 4; /* number of decimals in the calculated coordinates */
int fhelp = 0;
units = defUnits;
Expand Down
11 changes: 6 additions & 5 deletions src/geoszbtoyxh.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
Name: geoszbtoyxh.c
Version: 2.5
Date: 2021-10-10
Version: 2.6
Date: 2021-11-09
Author: zvezdochiot (https://github.com/zvezdochiot)
Author: Zoltan Siki (https://github.com/zsiki)
*
Expand Down Expand Up @@ -51,12 +51,13 @@ OKD-12 -2.6721 2.5453 1.2270
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <unistd.h>
#include <string.h>
#include <unistd.h>

#define PNAME "GeoSZBtoYXH"
#define PVERSION "2.5"
#define PVERSION "2.6"

#define defREarth 6370009.0
#define defUnits "DEG"

void geoszbtoyxhtitle()
Expand Down Expand Up @@ -150,7 +151,7 @@ int main(int argc, char *argv[])

int opt;
int decimals = 4; /* number of decimals in the calculated coordinates */
double RE = 6370009.0;
double RE = defREarth;
int fhelp = 0; /* default no help*/
units = defUnits;
while ((opt = getopt(argc, argv, "d:r:u:h")) != -1)
Expand Down

0 comments on commit 4f7d015

Please sign in to comment.