summaryrefslogtreecommitdiff
path: root/navit/tools/latlon2bookmark/latlon2bookmark.c
diff options
context:
space:
mode:
authorJoseph Herlant <herlantj@gmail.com>2018-05-25 22:06:51 -0700
committerJoseph Herlant <aerostitch@users.noreply.github.com>2018-05-25 22:17:50 -0700
commit8a76acb966f7059caf9d72c853175bd923b1e9d7 (patch)
tree1735178f7a0718831b88d2c36ea18a9955de3224 /navit/tools/latlon2bookmark/latlon2bookmark.c
parent032f15287b472f1a4b5349533f3e5b468684b281 (diff)
downloadnavit-8a76acb966f7059caf9d72c853175bd923b1e9d7.tar.gz
cleanup:global:Use astyle to reformat everything
Diffstat (limited to 'navit/tools/latlon2bookmark/latlon2bookmark.c')
-rw-r--r--navit/tools/latlon2bookmark/latlon2bookmark.c130
1 files changed, 60 insertions, 70 deletions
diff --git a/navit/tools/latlon2bookmark/latlon2bookmark.c b/navit/tools/latlon2bookmark/latlon2bookmark.c
index 4f5fe54cb..dfe1e5a7e 100644
--- a/navit/tools/latlon2bookmark/latlon2bookmark.c
+++ b/navit/tools/latlon2bookmark/latlon2bookmark.c
@@ -31,8 +31,7 @@
#include <math.h>
#include <string.h>
-int main( int argc, char **argv )
-{
+int main( int argc, char **argv ) {
char description[256];
char lngsign[10];
char latsign[10];
@@ -43,18 +42,17 @@ int main( int argc, char **argv )
int i;
int n;
- if ( argc < 4 )
- {
- printf("\n");
- printf("This program converts a lat/lon coordinates pair\n");
- printf("into a bookmark you can use with navit.\n");
- printf("This program expects 3 arguments in the following order:\n");
- printf("Lat, Lon and a description\n");
- printf("and will print a bookmark.\n");
- printf("for example: latlon2bookmark 51.980344 4.358005 this is my house \n");
- printf("\n");
- return 1;
- }
+ if ( argc < 4 ) {
+ printf("\n");
+ printf("This program converts a lat/lon coordinates pair\n");
+ printf("into a bookmark you can use with navit.\n");
+ printf("This program expects 3 arguments in the following order:\n");
+ printf("Lat, Lon and a description\n");
+ printf("and will print a bookmark.\n");
+ printf("for example: latlon2bookmark 51.980344 4.358005 this is my house \n");
+ printf("\n");
+ return 1;
+ }
lat=atof(argv[1]);
lng=atof(argv[2]);
@@ -62,74 +60,66 @@ int main( int argc, char **argv )
/* concatenate all parts of the description string */
strcpy(description, argv[3]);
n=0;
- for (i=4; i < argc; i++)
- {
- /* add spaces between the parts of the description */
- if ( i < argc )
- {
- strcat(description, " ");
- }
- strcat(description, argv[i]);
- n=n+1;
- }
-
- if ( lat < -90 )
- {
- printf("\n");
- printf("The first argument must be the lattitude\n");
- printf("and can't be smaller then -90 (southpole)\n");
- printf("\n");
- return 2;
- }
-
- if ( lat > 90 )
- {
- printf("\n");
- printf("The first argument must be the lattitude\n");
- printf("and can't be bigger then 90 (northpole)\n");
- printf("\n");
- return 3;
- }
-
- if ( lng < -180 )
- {
- printf("\n");
- printf("The second argument must be the longitude\n");
- printf("and can't be smaller then -180 (oposite the 0 meridian)\n");
- printf("\n");
- return 4;
- }
-
- if ( lng > 180 )
- {
- printf("\n");
- printf("The first argument must be the longitude\n");
- printf("and can't be bigger then 180 (oposite the 0 meridian)\n");
- printf("\n");
- return 5;
- }
+ for (i=4; i < argc; i++) {
+ /* add spaces between the parts of the description */
+ if ( i < argc ) {
+ strcat(description, " ");
+ }
+ strcat(description, argv[i]);
+ n=n+1;
+ }
+
+ if ( lat < -90 ) {
+ printf("\n");
+ printf("The first argument must be the lattitude\n");
+ printf("and can't be smaller then -90 (southpole)\n");
+ printf("\n");
+ return 2;
+ }
+
+ if ( lat > 90 ) {
+ printf("\n");
+ printf("The first argument must be the lattitude\n");
+ printf("and can't be bigger then 90 (northpole)\n");
+ printf("\n");
+ return 3;
+ }
+
+ if ( lng < -180 ) {
+ printf("\n");
+ printf("The second argument must be the longitude\n");
+ printf("and can't be smaller then -180 (oposite the 0 meridian)\n");
+ printf("\n");
+ return 4;
+ }
+
+ if ( lng > 180 ) {
+ printf("\n");
+ printf("The first argument must be the longitude\n");
+ printf("and can't be bigger then 180 (oposite the 0 meridian)\n");
+ printf("\n");
+ return 5;
+ }
/* convert the longitude to an integer */
intlng=lng*6371000.0*M_PI/180;
/* aparently if inlng < 0 , inlng needs to be inverted and a - sign used in the output */
strcpy(lngsign, "0x");
- if ( intlng < 0)
- {
- intlng=(intlng ^ 0xffffffff);
- strcpy(lngsign, "-0x");
- }
+ if ( intlng < 0) {
+ intlng=(intlng ^ 0xffffffff);
+ strcpy(lngsign, "-0x");
+ }
/* and the same for the latitude */
intlat=log(tan(M_PI_4+lat*M_PI/360))*6371000.0;
/* aparently if inlat < 0 , inlat needs to be inverted and a - sign used in the output */
strcpy(latsign, "0x");
- if ( intlat < 0)
- {
- intlat=(intlat ^ 0xffffffff);
- strcpy(latsign, "-0x");
- }
+ if ( intlat < 0) {
+ intlat=(intlat ^ 0xffffffff);
+ strcpy(latsign, "-0x");
+ }
/* print the bookmark */
fprintf(stderr,"\n");