aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKristian Evers <kristianevers@gmail.com>2018-06-05 21:58:40 +0200
committerKristian Evers <kristianevers@gmail.com>2018-06-05 23:28:49 +0200
commitb3322a80bd0255d44fe2e2478ada715559f7cb94 (patch)
tree8cf543af222bf5721abf5fc2919339c09fc3e417
parent524a335e0b80cf4ba8c68bf72321405a2803fca4 (diff)
downloadPROJ-b3322a80bd0255d44fe2e2478ada715559f7cb94.tar.gz
PROJ-b3322a80bd0255d44fe2e2478ada715559f7cb94.zip
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.
-rw-r--r--src/gie.c15
1 files changed, 15 insertions, 0 deletions
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)