From b3322a80bd0255d44fe2e2478ada715559f7cb94 Mon Sep 17 00:00:00 2001 From: Kristian Evers Date: Tue, 5 Jun 2018 21:58:40 +0200 Subject: Make gie read dms style coordinates proj_strtod doesn't read values like 123d45'678W so we need a bit of help from proj_dmstor. proj_strtod effectively ignores what comes after "d", so we use that fact that when dms is larger than d the value was stated in "dms" form. This could be avoided if proj_dmstor used the same proj_strtod() as gie, but that is not the case (yet). When we remove projects.h from the public API we can change that. --- src/gie.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'src') diff --git a/src/gie.c b/src/gie.c index ab09dc14..4030679f 100644 --- a/src/gie.c +++ b/src/gie.c @@ -681,7 +681,22 @@ Attempt to interpret args as a PJ_COORD. T.dimensions_given = 0; for (i = 0; i < 4; i++) { + /* proj_strtod doesn't read values like 123d45'678W so we need a bit */ + /* of help from proj_dmstor. proj_strtod effectively ignores what */ + /* comes after "d", so we use that fact that when dms is larger than */ + /* d the value was stated in "dms" form. */ + /* This could be avoided if proj_dmstor used the same proj_strtod() */ + /* as gie, but that is not the case (yet). When we remove projects.h */ + /* from the public API we can change that. */ + /* Note that the call to proj_dmstor needs to come first, since it */ + /* returns the wrong endp when reading numbers with _ separators. */ + /* A subsequent call to proj_strtod restores order. */ + double dms = PJ_TODEG(proj_dmstor (prev, (char **) &endp)); double d = proj_strtod (prev, (char **) &endp); + printf("d: %.5f dms: %.5f\n", d, dms); + /* TODO: When projects.h is removed, call proj_dmstor() in all cases */ + if (d < dms && dms < d + 1) + d = dms; /* Break out if there were no more numerals */ if (prev==endp) -- cgit v1.2.3