Skip to content

Commit 4f7d015

Browse files
committed
2.6: rescale to sea level
1 parent 0fa0357 commit 4f7d015

File tree

8 files changed

+78
-40
lines changed

8 files changed

+78
-40
lines changed

man/man1/geofindkey.1

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
.TH "GeoFindKey" 1 2.5 "10 Oct 2021" "User Manual"
1+
.TH "GeoFindKey" 1 2.6 "09 Nov 2021" "User Manual"
22

33
.SH NAME
44
geofindkey
@@ -12,10 +12,13 @@ geofindkey [option] input-file report-file
1212
.SH OPTIONS
1313
.TP
1414
-d N
15-
number of decimals in the result coordinates, default 4
15+
number of decimals in the result coordinates, default=4
1616
.TP
17-
-r
18-
rescale mode (bool, optional, default = false)
17+
-m str
18+
rescale mode {NORM,EQUAL,EARCH}, default=NORM
19+
.TP
20+
-r N.N
21+
radius Earth, default=6370009.0
1922
.TP
2023
-h
2124
help
@@ -36,7 +39,7 @@ input-file
3639
report-file
3740
(sample):
3841
key:
39-
(normal)
42+
(NORM)
4043
--0-----
4144
82135.4073
4245
47128.1437

man/man1/geofindkey2p.1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
.TH "GeoFindKey2Pow" 1 2.5 "10 Oct 2021" "User Manual"
1+
.TH "GeoFindKey2Pow" 1 2.6 "09 Nov 2021" "User Manual"
22

33
.SH NAME
44
geofindkey2p

man/man1/geositer500.1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
.TH "GeoSIter500" 1 2.5 "10 Oct 2021" "User Manual"
1+
.TH "GeoSIter500" 1 2.6 "09 Nov 2021" "User Manual"
22

33
.SH NAME
44
geositer500

man/man1/geoszbtoyxh.1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
.TH "GeoSZBtoYXH" 1 2.5 "10 Oct 2021" "User Manual"
1+
.TH "GeoSZBtoYXH" 1 2.6 "09 Nov 2021" "User Manual"
22

33
.SH NAME
44
geoszbtoyxh

src/geofindkey.c

Lines changed: 52 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
/*
22
Name: geofindkey.c
33
OldName: findkey.c
4-
Version: 2.5
5-
Date: 2021-10-10
4+
Version: 2.6
5+
Date: 2021-11-09
66
Author: Игорь Белов (https://gis-lab.info/forum/memberlist.php?mode=viewprofile&u=10457)
77
Author: zvezdochiot (https://github.com/zvezdochiot)
88
Author: Zoltan Siki (https://github.com/zsiki)
@@ -22,7 +22,8 @@ input file doc/data.dat:
2222
*
2323
output file report.dat:
2424
*
25-
key(normal):
25+
key:
26+
(NORM)
2627
--0-----
2728
82135.4073
2829
47128.1437
@@ -49,10 +50,14 @@ key(normal):
4950
#include <stdio.h>
5051
#include <stdlib.h>
5152
#include <math.h>
53+
#include <string.h>
5254
#include <unistd.h>
5355

5456
#define PNAME "GeoFindKey"
55-
#define PVERSION "2.5"
57+
#define PVERSION "2.6"
58+
59+
#define defMScale "NORM"
60+
#define defREarth 6370009.0
5661

5762
void geofindkeytitle()
5863
{
@@ -64,7 +69,8 @@ void geofindkeyusage()
6469
fprintf(stderr, "usage: geofindkey [option] input-file report-file\n");
6570
fprintf(stderr, "options:\n");
6671
fprintf(stderr, " -d N decimal after comma, default=4\n");
67-
fprintf(stderr, " -r rescale mode (bool, optional, default = false)\n");
72+
fprintf(stderr, " -m str rescale mode {NORM,EQUAL,EARCH}, default=NORM\n");
73+
fprintf(stderr, " -r N.N radius Earth, default=6370009.0\n");
6874
fprintf(stderr, " -h this help\n");
6975
fprintf(stderr, "\n");
7076
fprintf(stderr, "input-file(sample):\n");
@@ -79,7 +85,7 @@ void geofindkeyusage()
7985
fprintf(stderr, "\n");
8086
fprintf(stderr, "report-file(sample):\n");
8187
fprintf(stderr, " key:\n");
82-
fprintf(stderr, " (normal)\n");
88+
fprintf(stderr, " (NORM)\n");
8389
fprintf(stderr, " --0-----\n");
8490
fprintf(stderr, " 82135.4073\n");
8591
fprintf(stderr, " 47128.1437\n");
@@ -106,6 +112,17 @@ void geofindkeyusage()
106112
fprintf(stderr, " 0.0269 0.0248 0.0115 0.0003672639 0.0292\n");
107113
}
108114

115+
int IndexMScale(char* mscale)
116+
{
117+
if (!strcmp(mscale,"NORM"))
118+
return 0;
119+
if (!strcmp(mscale,"EQUAL"))
120+
return 1;
121+
if (!strcmp(mscale,"EARTH"))
122+
return 2;
123+
return 0;
124+
}
125+
109126
int main(int argc, char *argv[])
110127
{
111128
char buf[1024], name[32], format5[128], format7[128], format13[128];
@@ -118,18 +135,24 @@ int main(int argc, char *argv[])
118135
FILE *fp0, *fp1;
119136

120137
int opt;
138+
char* mscale;
121139
int decimals = 4; /* number of decimals in the calculated coordinates */
140+
double RE = defREarth;
122141
int frescale = 0;
142+
mscale = defMScale;
123143
int fhelp = 0;
124-
while ((opt = getopt(argc, argv, "d:rh")) != -1)
144+
while ((opt = getopt(argc, argv, "d:m:r:h")) != -1)
125145
{
126146
switch(opt)
127147
{
128148
case 'd':
129149
decimals = atoi(optarg);
130150
break;
151+
case 'm':
152+
mscale = optarg;
153+
break;
131154
case 'r':
132-
frescale = 1;
155+
RE = atof(optarg);
133156
break;
134157
case 'h':
135158
fhelp = 1;
@@ -163,6 +186,9 @@ int main(int argc, char *argv[])
163186
exit(EXIT_FAILURE);
164187
}
165188

189+
frescale = IndexMScale(mscale);
190+
if (frescale == 0) mscale = defMScale;
191+
166192
/* подсчитать сумму координат */
167193
n = 0;
168194
for (i = 0; i < 8; i++) {s[i] = 0.0;}
@@ -264,12 +290,25 @@ int main(int argc, char *argv[])
264290
/* найти вторичные параметры */
265291
scale = hypot(a[1][0], a[1][1]);
266292
rotation = atan2(a[1][1], a[1][0]);
267-
if (frescale > 0 && scale != 0.0)
293+
294+
if(frescale > 0)
268295
{
269-
a[1][0] /= scale;
270-
a[1][1] /= scale;
271-
a[1][2] = 1.0;
296+
if (scale > 0.0)
297+
{
298+
a[1][0] /= scale;
299+
a[1][1] /= scale;
300+
}
301+
a[1][2] = 1.0;
302+
if(frescale > 1)
303+
{
304+
if (RE > 0.0)
305+
{
306+
a[1][0] *= (1.0 - yc[2] / RE);
307+
a[1][1] *= (1.0 - yc[2] / RE);
308+
}
309+
}
272310
}
311+
273312
a[0][0] = yc[0] - a[1][0] * xc[0] + a[1][1] * xc[1];
274313
a[0][1] = yc[1] - a[1][1] * xc[0] - a[1][0] * xc[1];
275314
a[0][2] = yc[2] - a[1][2] * xc[2];
@@ -281,12 +320,7 @@ int main(int argc, char *argv[])
281320
exit(EXIT_FAILURE);
282321
}
283322
fprintf(fp1, "key:\n");
284-
if (frescale > 0)
285-
{
286-
fprintf(fp1, "(rescale)\n");
287-
} else {
288-
fprintf(fp1, "(normal)\n");
289-
}
323+
fprintf(fp1, "(%s)\n", mscale);
290324
fprintf(fp1, "--0-----\n");
291325
fprintf(fp1, "%.4f\n", a[0][0]);
292326
fprintf(fp1, "%.4f\n", a[0][1]);

src/geofindkey2p.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
Name: geofindkey2p.c
3-
Version: 2.5
4-
Date: 2021-10-10
3+
Version: 2.6
4+
Date: 2021-11-09
55
Author: zvezdochiot (https://github.com/zvezdochiot)
66
*
77
build:
@@ -57,7 +57,7 @@ output file report.dat:
5757
#include <unistd.h>
5858

5959
#define PNAME "GeoFindKey2Pow"
60-
#define PVERSION "2.5"
60+
#define PVERSION "2.6"
6161

6262
void geofindkey2ptitle()
6363
{

src/geositer500.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
Name: geositer500.c
3-
Version: 2.5
4-
Date: 2021-10-10
3+
Version: 2.6
4+
Date: 2021-11-09
55
Author: zvezdochiot (https://github.com/zvezdochiot)
66
Author: Zoltan Siki (https://github.com/zsiki)
77
*
@@ -50,12 +50,13 @@ OKD-12 3.8890 288.39138889 133.60805556
5050
#include <stdio.h>
5151
#include <stdlib.h>
5252
#include <math.h>
53-
#include <unistd.h>
5453
#include <string.h>
54+
#include <unistd.h>
5555

5656
#define PNAME "GeoSIter500"
57-
#define PVERSION "2.5"
57+
#define PVERSION "2.6"
5858

59+
#define defREarth 6370009.0
5960
#define defUnits "DEG"
6061

6162
void geositer500title()
@@ -150,9 +151,8 @@ int main(int argc, char *argv[])
150151
int np;
151152
FILE *fp0, *fp1;
152153

153-
double RE = 6370009.0;
154-
155154
int opt;
155+
double RE = defREarth;
156156
int decimals = 4; /* number of decimals in the calculated coordinates */
157157
int fhelp = 0;
158158
units = defUnits;

src/geoszbtoyxh.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
Name: geoszbtoyxh.c
3-
Version: 2.5
4-
Date: 2021-10-10
3+
Version: 2.6
4+
Date: 2021-11-09
55
Author: zvezdochiot (https://github.com/zvezdochiot)
66
Author: Zoltan Siki (https://github.com/zsiki)
77
*
@@ -51,12 +51,13 @@ OKD-12 -2.6721 2.5453 1.2270
5151
#include <stdio.h>
5252
#include <stdlib.h>
5353
#include <math.h>
54-
#include <unistd.h>
5554
#include <string.h>
55+
#include <unistd.h>
5656

5757
#define PNAME "GeoSZBtoYXH"
58-
#define PVERSION "2.5"
58+
#define PVERSION "2.6"
5959

60+
#define defREarth 6370009.0
6061
#define defUnits "DEG"
6162

6263
void geoszbtoyxhtitle()
@@ -150,7 +151,7 @@ int main(int argc, char *argv[])
150151

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

0 commit comments

Comments
 (0)