Skip to content

Commit

Permalink
Merge pull request #6 from Geo-Linux-Calculations/master
Browse files Browse the repository at this point in the history
fix #5
  • Loading branch information
zvezdochiot authored Nov 25, 2021
2 parents 86f87b1 + 32274c2 commit 9df24b7
Show file tree
Hide file tree
Showing 12 changed files with 253 additions and 18 deletions.
14 changes: 12 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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 $^
Expand All @@ -27,17 +27,22 @@ 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
groff -m man -T ps $(MANS)/helmparms3d.1 > man_helmparms3d.ps
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)
Expand All @@ -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
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
`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)

# helmert3d

## About
Expand Down
12 changes: 12 additions & 0 deletions examples/GRS80.txt
Original file line number Diff line number Diff line change
@@ -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
60 changes: 60 additions & 0 deletions man/man1/helmblhtoxyz.1
Original file line number Diff line number Diff line change
@@ -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

9 changes: 5 additions & 4 deletions man/man1/helmdiff3d.1
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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/
Expand Down Expand Up @@ -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
Expand Down
9 changes: 5 additions & 4 deletions man/man1/helmert3d.1
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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:

Expand Down Expand Up @@ -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
Expand Down
9 changes: 5 additions & 4 deletions man/man1/helmparms3d.1
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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:

Expand Down Expand Up @@ -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
136 changes: 136 additions & 0 deletions src/helmblhtoxyz.c
Original file line number Diff line number Diff line change
@@ -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, &lt, &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);
}
2 changes: 1 addition & 1 deletion src/helmdiff3d.c
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
2 changes: 1 addition & 1 deletion src/helmert3d.c
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
Loading

0 comments on commit 9df24b7

Please sign in to comment.