[mapcode] 39/56: Added LIMIT_TO_MICRODEGREES

Stefan Fritsch sf at moszumanska.debian.org
Wed Nov 2 23:27:30 UTC 2016


This is an automated email from the git hooks/post-receive script.

sf pushed a commit to annotated tag v2.0.2
in repository mapcode.

commit 29fcc8babad61115fd198ec3044989e341607ec5
Author: Rijn Buve <rijn at buve.nl>
Date:   Fri Jul 3 13:23:02 2015 +0200

    Added LIMIT_TO_MICRODEGREES
---
 utility/mapcode.cpp | 29 +++++++++++++++++++++--------
 1 file changed, 21 insertions(+), 8 deletions(-)

diff --git a/utility/mapcode.cpp b/utility/mapcode.cpp
index 6753ee0..b217453 100644
--- a/utility/mapcode.cpp
+++ b/utility/mapcode.cpp
@@ -43,6 +43,9 @@
 #include <time.h>
 #include "../mapcodelib/mapcoder.c"
 
+// Specific define to be able to limit output to microdegrees, for test files.
+#undef LIMIT_TO_MICRODEGREES
+
 #define my_isnan(x) (false)
 #define my_round(x) ((long) (floor((x) + 0.5)))
 
@@ -282,18 +285,28 @@ static void generateAndOutputMapcodes(double lat, double lon, int iShowError, in
     char* results[2 * MAX_NR_OF_MAPCODE_RESULTS];
     int context = 0;
 
-    while (lon > 180) {
-        lon -= 360;
+    while (lon > 180.0) {
+        lon -= 360.0;
+    }
+    while (lon < -180.0) {
+        lon += 360.0;
     }
-    while (lon < -180) {
-        lon += 360;
+    while (lat > 90.0) {
+        lat -= 180.0;
     }
-    while (lat > 90) {
-        lat -= 180;
+    while (lat < -90.0) {
+        lat += 180.0;
     }
-    while (lat < -90) {
-        lat += 180;
+
+#ifdef LIMIT_TO_MICRODEGREES
+    {
+        // Need to truncate lat/lon to microdegrees.
+        long lon32 = lon * 1000000.0;
+        long lat32 = lat * 1000000.0;
+        lon = (lon32 / 1000000.0);
+        lat = (lat32 / 1000000.0);
     }
+#endif
 
     const int nrResults = encodeLatLonToMapcodes_Deprecated(results, lat, lon, context, extraDigits);
     if (nrResults <= 0) {

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-grass/mapcode.git



More information about the Pkg-grass-devel mailing list