From 17f83c6f122db849a8877ef0ca641d4743f352cd Mon Sep 17 00:00:00 2001 From: Brendan Jurd Date: Sun, 15 Aug 2021 21:30:57 +1000 Subject: Add support for Degree Sign on input (#2791) This commit adds support in dsmtor() for a Degree Sign (U+00B0), encoded as UTF-8 (`\xc2\xb0`) or as a single byte (`\xb0`) (in ISO 8859 parts 1-4, 7-10, 13, 15, 16, and several Windows code pages), as an alternative symbol to `D`/`d` to designate the degree unit. Fixes #2712. --- docs/source/apps/cs2cs.rst | 2 +- src/dmstor.cpp | 63 +++++++++++++++++++++++++++++++------------- test/unit/gie_self_tests.cpp | 6 +++++ 3 files changed, 51 insertions(+), 20 deletions(-) diff --git a/docs/source/apps/cs2cs.rst b/docs/source/apps/cs2cs.rst index 909912df..abddae9e 100644 --- a/docs/source/apps/cs2cs.rst +++ b/docs/source/apps/cs2cs.rst @@ -261,7 +261,7 @@ The following script :: cs2cs +proj=latlong +datum=NAD83 +to +proj=utm +zone=10 +datum=NAD27 -r <= 4 ? '-' : '+'; ++s; diff --git a/test/unit/gie_self_tests.cpp b/test/unit/gie_self_tests.cpp index c7c1ddf5..f0d4ea86 100644 --- a/test/unit/gie_self_tests.cpp +++ b/test/unit/gie_self_tests.cpp @@ -442,6 +442,12 @@ TEST(gie, info_functions) { /* we can't expect perfect numerical accuracy so testing with a tolerance */ ASSERT_NEAR(-2.0, proj_dmstor(&buf[0], NULL), 1e-7); + /* test UTF-8 degree sign on DMS input */ + ASSERT_NEAR(0.34512432, proj_dmstor("19°46'27\"E", NULL), 1e-7); + + /* test ISO 8859-1, cp1252, et al. degree sign on DMS input */ + ASSERT_NEAR(0.34512432, proj_dmstor("19" "\260" "46'27\"E", NULL), 1e-7); + /* test proj_derivatives_retrieve() and proj_factors_retrieve() */ P = proj_create(PJ_DEFAULT_CTX, "+proj=merc +ellps=WGS84"); a = proj_coord(0, 0, 0, 0); -- cgit v1.2.3