diff options
| author | Kristian Evers <kristianevers@gmail.com> | 2018-06-06 21:24:11 +0200 |
|---|---|---|
| committer | Kristian Evers <kristianevers@gmail.com> | 2018-06-06 21:24:11 +0200 |
| commit | 8574765a7fb514b3d8ad7139df4f45a81f95e6c1 (patch) | |
| tree | c34a871b917f852d9098c51de3aaa48c1fefeca5 /src | |
| parent | 983d18a01fd0d6a3ecfc1974b919925ae73810f8 (diff) | |
| download | PROJ-8574765a7fb514b3d8ad7139df4f45a81f95e6c1.tar.gz PROJ-8574765a7fb514b3d8ad7139df4f45a81f95e6c1.zip | |
Correct bad use of proj_dmstor in gie.
The previous commits were added way to prematurely. The code was not
properly tested and it turned out to do more bad than good. This commit
hopefully fixes that. And this time it is backed up by tests!
DMS style coordinates should now be fully functional in gie. Finger
crossed.
Diffstat (limited to 'src')
| -rw-r--r-- | src/gie.c | 20 |
1 files changed, 13 insertions, 7 deletions
@@ -676,7 +676,9 @@ static PJ_COORD parse_coord (const char *args) { Attempt to interpret args as a PJ_COORD. ******************************************************************************/ int i; - const char *endp, *prev = args; + const char *endp; + const char *dmsendp; + const char *prev = args; PJ_COORD a = proj_coord (0,0,0,0); T.dimensions_given = 0; @@ -688,14 +690,18 @@ Attempt to interpret args as a PJ_COORD. /* 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); + double d = proj_strtod(prev, (char **) &endp); + double dms = PJ_TODEG(proj_dmstor (prev, (char **) &dmsendp)); /* TODO: When projects.h is removed, call proj_dmstor() in all cases */ - if (d < dms && dms < d + 1) + if (d != dms && fabs(d) < fabs(dms) && fabs(dms) < fabs(d) + 1) { d = dms; + endp = dmsendp; + } + /* A number like -81d00'00.000 will be parsed correctly by both */ + /* proj_strtod and proj_dmstor but only the latter will return */ + /* the correct end-pointer. */ + if (d == dms && endp != dmsendp) + endp = dmsendp; /* Break out if there were no more numerals */ if (prev==endp) |
