From 77f0370a8e438e59621dca78a896563f954087ab Mon Sep 17 00:00:00 2001 From: zvezdochiot Date: Wed, 12 May 2021 20:33:25 +0300 Subject: [PATCH 1/2] shields --- README.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/README.md b/README.md index fdc7a64..3c25693 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,9 @@ +![GitHub release (latest by date)](https://img.shields.io/github/v/release/Geo-Linux-Calculations/helmparms3d) +![GitHub Release Date](https://img.shields.io/github/release-date/Geo-Linux-Calculations/helmparms3d) +![GitHub repo size](https://img.shields.io/github/repo-size/Geo-Linux-Calculations/helmparms3d) +![GitHub all releases](https://img.shields.io/github/downloads/Geo-Linux-Calculations/helmparms3d/total) +![GitHub](https://img.shields.io/github/license/Geo-Linux-Calculations/helmparms3d) + # helmert3d ## About From 32274c2fc350d5a97fb8dd21f70e283230b06493 Mon Sep 17 00:00:00 2001 From: zvezdochiot Date: Thu, 25 Nov 2021 15:12:11 +0300 Subject: [PATCH 2/2] 1.0.2: fix #5: B-L-H to X-Y-Z --- Makefile | 14 ++++- README.md | 9 ++- examples/GRS80.txt | 12 ++++ man/man1/helmblhtoxyz.1 | 60 ++++++++++++++++++ man/man1/helmdiff3d.1 | 9 +-- man/man1/helmert3d.1 | 9 +-- man/man1/helmparms3d.1 | 9 +-- src/helmblhtoxyz.c | 136 ++++++++++++++++++++++++++++++++++++++++ src/helmdiff3d.c | 2 +- src/helmert3d.c | 2 +- src/helmert3d.h | 3 +- src/helmparms3d.c | 2 +- 12 files changed, 248 insertions(+), 19 deletions(-) create mode 100644 examples/GRS80.txt create mode 100644 man/man1/helmblhtoxyz.1 create mode 100644 src/helmblhtoxyz.c diff --git a/Makefile b/Makefile index 0db0882..c6b30d5 100644 --- a/Makefile +++ b/Makefile @@ -12,7 +12,7 @@ BINS=bin EXAMPS=examples MANS=man/man1 -all: helmert3d helmparms3d helmdiff3d +all: helmert3d helmparms3d helmdiff3d helmblhtoxyz libsvdm.a: $(SRCS)/svdm.c $(CC) $(CFLAGS) -c -o $(SRCS)/svdm.o $^ @@ -27,6 +27,9 @@ helmparms3d: $(SRCS)/helmparms3d.c libsvdm.a helmdiff3d: $(SRCS)/helmdiff3d.c $(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS) +helmblhtoxyz: $(SRCS)/helmblhtoxyz.c + $(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS) + pdfman: # not working for win groff -m man -T ps $(MANS)/helmert3d.1 > man_helmert3d.ps ps2pdf man_helmert3d.ps man_helmert3d.pdf @@ -34,10 +37,12 @@ pdfman: # not working for win ps2pdf man_helmparms3d.ps man_helmparms3d.pdf groff -m man -T ps $(MANS)/helmdiff3d.1 > man_helmdiff3d.ps ps2pdf man_helmdiff3d.ps man_helmdiff3d.pdf + groff -m man -T ps $(MANS)/helmblhtoxyz.1 > man_helmblhtoxyz.ps + ps2pdf man_helmblhtoxyz.ps man_helmblhtoxyz.pdf $(RM) *.ps clean: # not working for win - $(RM) helmparms3d helmert3d helmdiff3d libsvdm.a $(SRCS)/svdm.o *.pdf + $(RM) helmparms3d helmert3d helmdiff3d helmblhtoxyz libsvdm.a $(SRCS)/svdm.o *.pdf install: $(INSTALL) -d $(PREFIX)/$(BINS) @@ -46,19 +51,24 @@ install: $(INSTALL) -m 0755 helmparms3d $(PREFIX)/$(BINS) $(INSTALL) -m 0755 helmert3d $(PREFIX)/$(BINS) $(INSTALL) -m 0755 helmdiff3d $(PREFIX)/$(BINS) + $(INSTALL) -m 0755 helmblhtoxyz $(PREFIX)/$(BINS) $(INSTALL) -m 0644 README.md $(DOCS) $(INSTALL) -m 0644 LICENSE $(DOCS) $(INSTALL) -m 0644 $(EXAMPS)/testpoints_src.txt $(DOCS)/$(EXAMPS) $(INSTALL) -m 0644 $(EXAMPS)/testpoints_dest.txt $(DOCS)/$(EXAMPS) + $(INSTALL) -m 0644 $(EXAMPS)/GRS80.txt $(DOCS)/$(EXAMPS) $(INSTALL) -m 0644 $(MANS)/helmparms3d.1 $(PREFIX)/$(MANS) $(INSTALL) -m 0644 $(MANS)/helmert3d.1 $(PREFIX)/$(MANS) $(INSTALL) -m 0644 $(MANS)/helmdiff3d.1 $(PREFIX)/$(MANS) + $(INSTALL) -m 0644 $(MANS)/helmblhtoxyz.1 $(PREFIX)/$(MANS) uninstall: $(RM) $(PREFIX)/$(BINS)/helmparms3d $(RM) $(PREFIX)/$(BINS)/helmert3d $(RM) $(PREFIX)/$(BINS)/helmdiff3d + $(RM) $(PREFIX)/$(BINS)/helmblhtoxyz $(RMD) $(DOCS) $(RM) $(PREFIX)/$(MANS)/helmparms3d.1 $(RM) $(PREFIX)/$(MANS)/helmert3d.1 $(RM) $(PREFIX)/$(MANS)/helmdiff3d.1 + $(RM) $(PREFIX)/$(MANS)/helmblhtoxyz.1 diff --git a/README.md b/README.md index 3c25693..f311bae 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,15 @@ +`Origin :` +![GitHub release (latest by date)](https://img.shields.io/github/v/release/dr-ni/helmert3d) +![GitHub Release Date](https://img.shields.io/github/release-date/dr-ni/helmert3d) +![GitHub repo size](https://img.shields.io/github/repo-size/dr-ni/helmert3d) +![GitHub all releases](https://img.shields.io/github/downloads/dr-ni/helmert3d/total) +![GitHub](https://img.shields.io/github/license/dr-ni/helmert3d) +`GLC.ORG:` ![GitHub release (latest by date)](https://img.shields.io/github/v/release/Geo-Linux-Calculations/helmparms3d) ![GitHub Release Date](https://img.shields.io/github/release-date/Geo-Linux-Calculations/helmparms3d) ![GitHub repo size](https://img.shields.io/github/repo-size/Geo-Linux-Calculations/helmparms3d) ![GitHub all releases](https://img.shields.io/github/downloads/Geo-Linux-Calculations/helmparms3d/total) -![GitHub](https://img.shields.io/github/license/Geo-Linux-Calculations/helmparms3d) +![GitHub](https://img.shields.io/github/license/Geo-Linux-Calculations/helmparms3d) # helmert3d diff --git a/examples/GRS80.txt b/examples/GRS80.txt new file mode 100644 index 0000000..3b0801c --- /dev/null +++ b/examples/GRS80.txt @@ -0,0 +1,12 @@ +GRS80 6378137.0 6356752.3141 +56.32258375 21.22652722 0 +56.4935 21.783 0 +56.61155556 22.93708333 0 +56.48455556 23.55005556 0 +56.48191667 24.31558333 0 +56.59155556 25.15272222 0 +56.25533333 25.54025 0 +56.01013889 26.22444444 0 +55.69546942 26.61753336 0 +56.94747222 24.10877528 0 +56.94747556 24.1087875 0 diff --git a/man/man1/helmblhtoxyz.1 b/man/man1/helmblhtoxyz.1 new file mode 100644 index 0000000..30e9435 --- /dev/null +++ b/man/man1/helmblhtoxyz.1 @@ -0,0 +1,60 @@ +.TH "helmblhtoxyz" 1 1.0.2 "25 Nov 2021" "User Manual" + +.SH NAME +helmblhtoxyz + +.SH DESCRIPTION +3D calculate from B-L-H to X-Y-Z for Helmert + +.SH SYNOPSIS +helmblhtoxyz blh_src_infilename [xyz_diff_outfilename] + +.SH FILES +.TP +blh data file format: + + name a b + B[1] L[1] H[1] + .. .. .. + .. .. .. + B[n] L[n] H[n] +.TP +xyz data file format: + + X[1] Y[1] Z[1] + .. .. .. + .. .. .. + H[n] Y[n] Z[n] + +.SH EXAMPLE + export EXAMP=/usr/share/doc/helmert3d/examples/ + + helmblhtoxyz $EXAMP/GRS80.txt XYH.txt + +.SH COPYRIGHT +helmert3d: + +Copyright (c) 2020 U. Niethammer + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or (at +your option) any later version. + +This program is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + +.SH SEE ALSO + helmparms3d(1), + helmert3d(1), + helmdiff3d(1) + +.SH CONTACT + Website: https://github.com/dr-ni/helmert3d + diff --git a/man/man1/helmdiff3d.1 b/man/man1/helmdiff3d.1 index ff8101d..f5b579f 100644 --- a/man/man1/helmdiff3d.1 +++ b/man/man1/helmdiff3d.1 @@ -1,4 +1,4 @@ -.TH "helmdiff3d" 1 1.0.1 "11 Feb 2021" "User Manual" +.TH "helmdiff3d" 1 1.0.2 "25 Nov 2021" "User Manual" .SH NAME helmdiff3d @@ -13,10 +13,10 @@ helmdiff3d [xyz_src_infilename] [xyz_dest_infilename] [xyz_diff_outfilename] .TP xyz data file format: - x[1] y[1] z[1] + X[1] Y[1] Z[1] .. .. .. .. .. .. - x[n] y[n] z[n] + X[n] Y[n] Z[n] .SH EXAMPLE export EXAMP=/usr/share/doc/helmert3d/examples/ @@ -46,7 +46,8 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. .SH SEE ALSO helmparms3d(1), - helmert3d(1) + helmert3d(1), + helmblhtoxyz(1) .SH CONTACT Website: https://github.com/dr-ni/helmert3d diff --git a/man/man1/helmert3d.1 b/man/man1/helmert3d.1 index 5781fff..26e26a4 100644 --- a/man/man1/helmert3d.1 +++ b/man/man1/helmert3d.1 @@ -1,4 +1,4 @@ -.TH "helmert3d" 1 1.0.0 "29 Oct 2020" "User Manual" +.TH "helmert3d" 1 1.0.2 "25 Nov 2021" "User Manual" .SH NAME helmert3d @@ -23,10 +23,10 @@ helmert3d [xyz_src_infilename] [param_infilename] [xyz_outfilename] .TP xyz data file format: - x[1] y[1] z[1] + X[1] Y[1] Z[1] .. .. .. .. .. .. - x[n] y[n] z[n] + X[n] Y[n] Z[n] .TP helmert parameter file format: @@ -62,7 +62,8 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. .SH SEE ALSO helmparms3d(1), - helmdiff3d(1) + helmdiff3d(1), + helmblhtoxyz(1) .SH CONTACT Website: https://github.com/dr-ni/helmert3d diff --git a/man/man1/helmparms3d.1 b/man/man1/helmparms3d.1 index 771f705..88508d7 100644 --- a/man/man1/helmparms3d.1 +++ b/man/man1/helmparms3d.1 @@ -1,4 +1,4 @@ -.TH "helmparms3d" 1 1.0.0 "29 Oct 2020" "User Manual" +.TH "helmparms3d" 1 1.0.2 "25 Nov 2021" "User Manual" .SH NAME helmparms3d @@ -23,10 +23,10 @@ helmparms3d [xyz_src_infilename] [xyz_dest_infilename] [parms_outfilename] .TP xyz data file format: - x[1] y[1] z[1] + X[1] Y[1] Z[1] .. .. .. .. .. .. - x[n] y[n] z[n] + X[n] Y[n] Z[n] .TP helmert parameter file format: @@ -89,7 +89,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. .SH SEE ALSO helmert3d(1), - helmdiff3d(1) + helmdiff3d(1), + helmblhtoxyz(1) .SH CONTACT Website: https://github.com/dr-ni/helmert3d diff --git a/src/helmblhtoxyz.c b/src/helmblhtoxyz.c new file mode 100644 index 0000000..e2c4b15 --- /dev/null +++ b/src/helmblhtoxyz.c @@ -0,0 +1,136 @@ +/* Copyright (C) 2020 U. Niethammer, https://github.com/dr-ni/helmert3d + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or (at + * your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +#include "helmert3d.h" + +static size_t get_m_size(char *filename) +{ + FILE *ptsfile; + char buf[256]; + size_t linecount=0; + + memset(buf, 0, sizeof(buf)); + ptsfile = fopen( filename, "r"); + if(ptsfile == NULL) + { + fprintf(stderr,"Error opening %s\r\n",filename); + exit(EXIT_FAILURE); + } + // Count points + while(fgets( buf, 128, ptsfile)!=NULL) + { + if( strcmp(buf,"\n") != 0 && strcmp(buf,"\r\n") != 0 && strcmp(buf,"\0") != 0) + { + linecount++; + } + else + { + fprintf(stderr,"Error, %s: wrong data format\n",filename); + exit(EXIT_FAILURE); + } + } + (void)fclose(ptsfile); + return(linecount); +} + +int main(int argc, char* argv[]) +{ + FILE *ifile; + FILE *ofile; + char *ifilename = ""; + char *ofilename = "out.xyz"; + char ibuf[256], name[128]; + double a = 6378137.0, b = 6356752.3142; + double bc, bs, lc, ls, ta, tb, nb, lt, bt, ht, xt, yt, zt; + size_t s = 0, i = 0; + int stat = 0; + + fprintf(stdout,"\n*******************************\n"); + fprintf(stdout, "* helmblhtoxyz v%s *\n",VERS); + fprintf(stdout, "* (c) U. Niethammer 2020 *\n"); + fprintf(stdout, "*******************************\n"); + + if(argc < 2) + { + fprintf(stdout,"\nSyntax: %s blh_src_infilename [xyz_dest_infilename]\n\n",argv[0]); + fprintf(stdout,"blh data file format:\n"); + fprintf(stdout," Name a b\n B[1] L[1] H[1]\n .. .. ..\n .. .. ..\n B[n] L[n] H[n]\n\n"); + fprintf(stdout,"xyz data file format:\n"); + fprintf(stdout," X[1] Y[1] Z[1]\n .. .. ..\n .. .. ..\n X[n] Y[n] Z[n]\n\n"); + exit(EXIT_FAILURE); + } + fprintf(stdout,"Reading points...\n"); + ifilename = argv[1]; + s = get_m_size(ifilename) - 1; + fprintf(stdout,"Found %lu points\n",(unsigned long)s); + ifile = fopen( ifilename, "r"); + if(ifile == NULL) + { + fprintf(stderr,"Error opening %s\n",ifilename); + exit(EXIT_FAILURE); + } + if(argc > 2) + { + ofilename = argv[2]; + } + ofile = fopen( ofilename, "w"); + if(ofile == NULL) + { + fprintf(stderr,"Error writing %s\n",ofilename); + exit(EXIT_FAILURE); + } + + fprintf(stdout,"Starting calculate...\n"); + while(fgets( ibuf, 128, ifile)!=NULL) + { + if (i == 0) + { + stat = sscanf( ibuf, "%s %lf %lf", &name, &a, &b); + if(stat != 3) + { + fprintf(stderr,"Error wrong data format in %s\n",ifilename); + exit(EXIT_FAILURE); + } + fprintf(stdout,"Ellipsoid %s, a = %lf, b = %lf\n", name, a, b); + } + else + { + stat=sscanf( ibuf, "%lf %lf %lf", &bt, <, &ht); + if(stat != 3) + { + fprintf(stderr,"Error wrong data format in %s\n",ifilename); + exit(EXIT_FAILURE); + } + bc = cos(M_PI / 180.0 * bt); + bs = sin(M_PI / 180.0 * bt); + lc = cos(M_PI / 180.0 * lt); + ls = sin(M_PI / 180.0 * lt); + ta = a * bc; + tb = b * bs; + nb = (a * a) / sqrt(ta * ta + tb * tb); + xt = (nb + ht) * bc * lc; + yt = (nb + ht) * bc * ls; + zt = (b * b / a / a * nb + ht) * bs; + fprintf(ofile,"%lf %lf %lf\n", xt , yt , zt); + } + i++; + } + fprintf(stdout,"...done\nResults written to %s\n", ofilename); + (void)fclose(ifile); + (void)fclose(ofile); + return(0); +} diff --git a/src/helmdiff3d.c b/src/helmdiff3d.c index c6a42c6..4be2110 100644 --- a/src/helmdiff3d.c +++ b/src/helmdiff3d.c @@ -71,7 +71,7 @@ int main(int argc, char* argv[]) { fprintf(stdout,"\nSyntax: %s [xyz_src_infilename] [xyz_dest_infilename] [xyz_diff_outfilename]\n\n",argv[0]); fprintf(stdout,"xyz data file format:\n"); - fprintf(stdout," x[1] y[1] z[1]\n .. .. ..\n .. .. ..\n x[n] y[n] z[n]\n\n"); + fprintf(stdout," X[1] Y[1] Z[1]\n .. .. ..\n .. .. ..\n X[n] Y[n] Z[n]\n\n"); exit(EXIT_FAILURE); } fprintf(stdout,"Reading points...\n"); diff --git a/src/helmert3d.c b/src/helmert3d.c index 36b7f71..ada3139 100644 --- a/src/helmert3d.c +++ b/src/helmert3d.c @@ -77,7 +77,7 @@ int main(int argc, char* argv[]) fprintf(stdout,"helmert parameter file format:\n"); fprintf(stdout," r11 r12 r13\n r21 r22 r23\n r31 r32 r33\n tx ty tz\n s\n\n"); fprintf(stdout,"xyz data file format:\n"); - fprintf(stdout," x[1] y[1] z[1]\n .. .. ..\n .. .. ..\n x[n] y[n] z[n]\n\n"); + fprintf(stdout," X[1] Y[1] Z[1]\n .. .. ..\n .. .. ..\n X[n] Y[n] Z[n]\n\n"); exit(EXIT_FAILURE); } fprintf(stdout,"Reading points...\n"); diff --git a/src/helmert3d.h b/src/helmert3d.h index b835a32..dba2188 100644 --- a/src/helmert3d.h +++ b/src/helmert3d.h @@ -21,7 +21,8 @@ #include #include #include -#define VERS "1.0.1" +#include +#define VERS "1.0.2" #define DEBUG 0 #endif // HELMERT3D_H diff --git a/src/helmparms3d.c b/src/helmparms3d.c index e2d3b28..5f5d19e 100644 --- a/src/helmparms3d.c +++ b/src/helmparms3d.c @@ -307,7 +307,7 @@ int main(int argc, char* argv[]) fprintf(stderr,"helmert parameter file format:\n"); fprintf(stderr," r11 r12 r13\n r21 r22 r23\n r31 r32 r33\n tx ty tz\n s\n\n"); fprintf(stderr,"xyz data file format:\n"); - fprintf(stderr," x[1] y[1] z[1]\n .. .. ..\n .. .. ..\n x[n] y[n] z[n]\n\n"); + fprintf(stderr," X[1] Y[1] Z[1]\n .. .. ..\n .. .. ..\n X[n] Y[n] Z[n]\n\n"); exit(EXIT_FAILURE); } src_pts_name = argv[1];