From 4f7d015c3a058aeb4ca8392e64d5f2eb05cfb386 Mon Sep 17 00:00:00 2001 From: zvezdochiot Date: Tue, 9 Nov 2021 12:44:29 +0300 Subject: [PATCH] 2.6: rescale to sea level --- man/man1/geofindkey.1 | 13 +++++--- man/man1/geofindkey2p.1 | 2 +- man/man1/geositer500.1 | 2 +- man/man1/geoszbtoyxh.1 | 2 +- src/geofindkey.c | 70 ++++++++++++++++++++++++++++++----------- src/geofindkey2p.c | 6 ++-- src/geositer500.c | 12 +++---- src/geoszbtoyxh.c | 11 ++++--- 8 files changed, 78 insertions(+), 40 deletions(-) diff --git a/man/man1/geofindkey.1 b/man/man1/geofindkey.1 index 53c46ca..0c928ab 100644 --- a/man/man1/geofindkey.1 +++ b/man/man1/geofindkey.1 @@ -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 @@ -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 @@ -36,7 +39,7 @@ input-file report-file (sample): key: - (normal) + (NORM) --0----- 82135.4073 47128.1437 diff --git a/man/man1/geofindkey2p.1 b/man/man1/geofindkey2p.1 index 49b03e8..1eae094 100644 --- a/man/man1/geofindkey2p.1 +++ b/man/man1/geofindkey2p.1 @@ -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 diff --git a/man/man1/geositer500.1 b/man/man1/geositer500.1 index d4e4b75..0ec17fc 100644 --- a/man/man1/geositer500.1 +++ b/man/man1/geositer500.1 @@ -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 diff --git a/man/man1/geoszbtoyxh.1 b/man/man1/geoszbtoyxh.1 index b899441..b50fd6d 100644 --- a/man/man1/geoszbtoyxh.1 +++ b/man/man1/geoszbtoyxh.1 @@ -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 diff --git a/src/geofindkey.c b/src/geofindkey.c index 70e5b15..c09f3d5 100644 --- a/src/geofindkey.c +++ b/src/geofindkey.c @@ -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) @@ -22,7 +22,8 @@ input file doc/data.dat: * output file report.dat: * -key(normal): +key: +(NORM) --0----- 82135.4073 47128.1437 @@ -49,10 +50,14 @@ key(normal): #include #include #include +#include #include #define PNAME "GeoFindKey" -#define PVERSION "2.5" +#define PVERSION "2.6" + +#define defMScale "NORM" +#define defREarth 6370009.0 void geofindkeytitle() { @@ -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"); @@ -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"); @@ -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]; @@ -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; @@ -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;} @@ -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]; @@ -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]); diff --git a/src/geofindkey2p.c b/src/geofindkey2p.c index 7661b93..f712f00 100644 --- a/src/geofindkey2p.c +++ b/src/geofindkey2p.c @@ -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: @@ -57,7 +57,7 @@ output file report.dat: #include #define PNAME "GeoFindKey2Pow" -#define PVERSION "2.5" +#define PVERSION "2.6" void geofindkey2ptitle() { diff --git a/src/geositer500.c b/src/geositer500.c index d0f548f..80ffe43 100644 --- a/src/geositer500.c +++ b/src/geositer500.c @@ -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) * @@ -50,12 +50,13 @@ OKD-12 3.8890 288.39138889 133.60805556 #include #include #include -#include #include +#include #define PNAME "GeoSIter500" -#define PVERSION "2.5" +#define PVERSION "2.6" +#define defREarth 6370009.0 #define defUnits "DEG" void geositer500title() @@ -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; diff --git a/src/geoszbtoyxh.c b/src/geoszbtoyxh.c index bd111b2..fd73675 100644 --- a/src/geoszbtoyxh.c +++ b/src/geoszbtoyxh.c @@ -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) * @@ -51,12 +51,13 @@ OKD-12 -2.6721 2.5453 1.2270 #include #include #include -#include #include +#include #define PNAME "GeoSZBtoYXH" -#define PVERSION "2.5" +#define PVERSION "2.6" +#define defREarth 6370009.0 #define defUnits "DEG" void geoszbtoyxhtitle() @@ -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)