diff options
author | Joseph Herlant <herlantj@gmail.com> | 2018-05-25 22:06:51 -0700 |
---|---|---|
committer | Joseph Herlant <aerostitch@users.noreply.github.com> | 2018-05-25 22:17:50 -0700 |
commit | 8a76acb966f7059caf9d72c853175bd923b1e9d7 (patch) | |
tree | 1735178f7a0718831b88d2c36ea18a9955de3224 /navit/tools/gpx2navit_txt/src/utils.c | |
parent | 032f15287b472f1a4b5349533f3e5b468684b281 (diff) | |
download | navit-8a76acb966f7059caf9d72c853175bd923b1e9d7.tar.gz |
cleanup:global:Use astyle to reformat everything
Diffstat (limited to 'navit/tools/gpx2navit_txt/src/utils.c')
-rw-r--r-- | navit/tools/gpx2navit_txt/src/utils.c | 135 |
1 files changed, 64 insertions, 71 deletions
diff --git a/navit/tools/gpx2navit_txt/src/utils.c b/navit/tools/gpx2navit_txt/src/utils.c index 4a215fd9d..11fae97d1 100644 --- a/navit/tools/gpx2navit_txt/src/utils.c +++ b/navit/tools/gpx2navit_txt/src/utils.c @@ -32,86 +32,82 @@ double getDistance(double _x, double _y, double x, double y); // todo void closeDbfFiles(dbfhandles * dbfs); void *myMallocRep(size_t size, const char *fileName, int line); -void checkEllpsUnit(char *unit) -{ -/* - * checks ellipse unit can be used by proj4 - */ +void checkEllpsUnit(char *unit) { + /* + * checks ellipse unit can be used by proj4 + */ int isOK = 0; struct PJ_ELLPS *el; /* project.h of proj4 */ for (el = pj_ellps; el->id; ++el) { - if (!strcmp(el->id, unit)) { - isOK = 1; - } + if (!strcmp(el->id, unit)) { + isOK = 1; + } } if (!isOK) { - fputs - ("The ellipse argument is not correct or supported by libproj\n", - stderr); - fputs("You can choose the argument from a list below.\n\n", - stderr); - for (el = pj_ellps; el->id; el++) { - printf("%10s\t%s\n", el->id, el->name); - } - exit(ERR_ELLPSUNIT); + fputs + ("The ellipse argument is not correct or supported by libproj\n", + stderr); + fputs("You can choose the argument from a list below.\n\n", + stderr); + for (el = pj_ellps; el->id; el++) { + printf("%10s\t%s\n", el->id, el->name); + } + exit(ERR_ELLPSUNIT); } } -double checkLengthUnit(char *unit) -{ -/* - * checks length unit can be used by proj4 - * then returns unit value to meter - */ +double checkLengthUnit(char *unit) { + /* + * checks length unit can be used by proj4 + * then returns unit value to meter + */ int isOK = 0; double to_meter = 0; struct PJ_UNITS *ut; /* project.h of proj4 */ for (ut = pj_units; ut->id; ut++) { - if (!strcmp(ut->id, unit)) { - isOK = 1; - to_meter = atof(ut->to_meter); - } + if (!strcmp(ut->id, unit)) { + isOK = 1; + to_meter = atof(ut->to_meter); + } } if (!isOK) { - fputs - ("The length unit argument is not correct or supported by libproj.\n", - stderr); - fputs("You can choose the argument from a list below.\n\n", - stderr); - for (ut = pj_units; ut->id; ut++) { - printf("%s\t%s\n", ut->id, ut->name); - } - exit(ERR_LENGTHUNIT); + fputs + ("The length unit argument is not correct or supported by libproj.\n", + stderr); + fputs("You can choose the argument from a list below.\n\n", + stderr); + for (ut = pj_units; ut->id; ut++) { + printf("%s\t%s\n", ut->id, ut->name); + } + exit(ERR_LENGTHUNIT); } return to_meter; } -int checkTimeUnit(char *unit) -{ +int checkTimeUnit(char *unit) { char *u[8] = { "sec", "s", "min", "m", "hour", "h", "day", "d" }; int p[8] = { 1, 1, 60, 60, 3600, 3600, 86400, 86400 }; int i, to_sec = 0; for (i = 0; i < 8; i++) { - if (!strcmp(u[i], unit)) { - to_sec = p[i]; - } + if (!strcmp(u[i], unit)) { + to_sec = p[i]; + } } if (!to_sec) { - fputs("The time unit argument is not correct.\n", stderr); - fputs("You can choose the argument from sec, min, hour or day.\n", - stderr); - exit(ERR_TIMEUNIT); + fputs("The time unit argument is not correct.\n", stderr); + fputs("You can choose the argument from sec, min, hour or day.\n", + stderr); + exit(ERR_TIMEUNIT); } return to_sec; } -double getTimeInterval(char *_t, char *t) -{ -/* - * Returns a time interval between _t and t. - * The arguments should be "YYYY-MM-DDThh:mm:ssZ" (xml schema - * datetime format without time zone) format. - */ +double getTimeInterval(char *_t, char *t) { + /* + * Returns a time interval between _t and t. + * The arguments should be "YYYY-MM-DDThh:mm:ssZ" (xml schema + * datetime format without time zone) format. + */ double ti; struct tm _tt; struct tm tt; @@ -119,11 +115,11 @@ double getTimeInterval(char *_t, char *t) memset(&_tt, 0, sizeof(_tt)); memset(&tt, 0, sizeof(tt)); sscanf(_t, "%d-%d-%dT%d:%d:%dZ", &_tt.tm_year, &_tt.tm_mon, - &_tt.tm_mday, &_tt.tm_hour, &_tt.tm_min, &_tt.tm_sec); + &_tt.tm_mday, &_tt.tm_hour, &_tt.tm_min, &_tt.tm_sec); _tt.tm_year -= 1900; _tt.tm_mon -= 1; sscanf(t, "%d-%d-%dT%d:%d:%d", &tt.tm_year, &tt.tm_mon, &tt.tm_mday, - &tt.tm_hour, &tt.tm_min, &tt.tm_sec); + &tt.tm_hour, &tt.tm_min, &tt.tm_sec); tt.tm_year -= 1900; tt.tm_mon -= 1; _tmt = mktime(&_tt); @@ -132,21 +128,19 @@ double getTimeInterval(char *_t, char *t) return ti; } -double getSpeed(double length, double ti, double to_meter, int to_sec) -{ -/* - * Culculates speed from length and time. - */ +double getSpeed(double length, double ti, double to_meter, int to_sec) { + /* + * Culculates speed from length and time. + */ double speed; if (!length || !ti) - speed = 0; + speed = 0; else - speed = (length / to_meter) / (ti / to_sec); + speed = (length / to_meter) / (ti / to_sec); return speed; } -double getDistanceCore(char *p1, char *l1, char *p2, char *l2) -{ +double getDistanceCore(char *p1, char *l1, char *p2, char *l2) { /* * Culculates a geodesic length between two points * using geod_*.c @@ -159,8 +153,7 @@ double getDistanceCore(char *p1, char *l1, char *p2, char *l2) return geod_S; } -double getDistance(double _x, double _y, double x, double y) -{ +double getDistance(double _x, double _y, double x, double y) { /* * Culculates a geodesic length between two points */ @@ -176,9 +169,9 @@ double getDistance(double _x, double _y, double x, double y) //todo void closeShpFiles(shphandles * shps) //{ - /* - * Closes all SHP files if they opened - */ +/* + * Closes all SHP files if they opened + */ // if (shps->wpt) // SHPClose(shps->wpt); // if (shps->trk) @@ -197,9 +190,9 @@ double getDistance(double _x, double _y, double x, double y) //todo void closeDbfFiles(dbfhandles * dbfs) //{ - /* - * Closes all DBF files if they opened - */ +/* + * Closes all DBF files if they opened + */ // if (dbfs->wpt) // DBFClose(dbfs->wpt); // if (dbfs->trk) |