[mapcode] 03/18: Prepared for 1.40 added extraDigits to --random; improved help text

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


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

sf pushed a commit to annotated tag v1.40
in repository mapcode.

commit 28548ec07cda97cba1f0c9484a60101c147c51be
Author: Rijn Buve <rijn at buve.nl>
Date:   Wed Sep 17 11:27:50 2014 +0200

    Prepared for 1.40 added extraDigits to --random; improved help text
---
 README                | 23 +++++++++++++++++------
 example/mapcode.cpp   | 37 +++++++++++++++++++++++++++----------
 mapcodelib/basics.h   | 16 ++++++++++++++++
 mapcodelib/mapcoder.c |  4 ++--
 mapcodelib/mapcoder.h |  1 -
 5 files changed, 62 insertions(+), 19 deletions(-)

diff --git a/README b/README
index 8e9be4d..a9a739e 100644
--- a/README
+++ b/README
@@ -49,7 +49,7 @@ of how to use the library.
 To build the original Mapcode tool, execute:
 
   cd example
-  gcc mapcode.c -o mapcode
+  gcc mapcode.cpp -o mapcode
 
 For help, simply execute the binary file 'mapcode' without no arguments.
 This tool provides a rather extensive command-line interface to encode and
@@ -61,34 +61,45 @@ MAPCODE LIBRARY - RELEASE NOTES
 -------------------------------------------------------------------------------
 
 1.40
+
     Added extraDigits parameter to allow high-precision mapcodes to be generated.
 
 1.33
-    Fix to not remove valid results just across the edge of a territory. Improved interface readability
-    and renamed methods to more readable forms.
+
+    Fix to not remove valid results just across the edge of a territory.
+    Improved interface readability and renamed methods to more readable forms.
 
 1.32
-    Added encodeLatLonToSingleMapcode(); fixed 1.29 so no country-wide alternative is produced in edge cases; prevent FIJI failing to
-    decode at exactly 180 degrees.
+
+    Added encodeLatLonToSingleMapcode(); fixed 1.29 so no country-wide alternative
+    is produced in edge cases; prevent FIJI failing to decode at exactly 180 degrees.
 
 1.31
+
     Added compareWithMapcodeFormat().
 
 1.30
+
     IUpdated the documentation and extended it with examples and suggestions.
 
 1.29
+
     Also generate country-wide alternative mapcodes for states.
 
 1.28
-    Bug fix for the needless generation of 7-letter alternatives to short mapcodes in large states in India.
+
+    Bug fix for the needless generation of 7-letter alternatives to short mapcodes
+    in large states in India.
 
 1.27
+
     Improved (faster) implementation of the function isInArea.
 
 1.26
+
     Added alias OD ("Odisha") for indian state OR ("Orissa").
 
 1.25
+
     Initial release to the public domain.
 
diff --git a/example/mapcode.cpp b/example/mapcode.cpp
index 7b3457b..7bf03c6 100644
--- a/example/mapcode.cpp
+++ b/example/mapcode.cpp
@@ -1,6 +1,17 @@
-/**
- * Copyright (C) 2014 Stichting Mapcode Foundation
- * For terms of use refer to http://www.mapcode.com/downloads.html
+/*
+ * Copyright (C) 2014 Stichting Mapcode Foundation (http://www.mapcode.com)
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
  */
 
 /**
@@ -31,7 +42,6 @@
 #define my_isnan(x) (false)
 #define my_round(x) ((long) (floor((x) + 0.5)))
 
-static const char*  VERSION             = "1";
 static const int    SELF_CHECK          = 1;
 static const int    SELF_CHECK_EXIT     = 0;
 
@@ -64,7 +74,7 @@ static double   lonLargestNrOfResults   = 0.0;
  * whenever a incorrect amount or combination of parameters is entered.
  */
 static void usage(const char* appName) {
-    printf("MAPCODE (version %s.%s%s)\n", mapcode_cversion, VERSION, SELF_CHECK ? ", self-checking" : "");
+    printf("MAPCODE (version %s%s)\n", mapcode_cversion, SELF_CHECK ? ", self-checking" : "");
     printf("Copyright (C) 2014 Stichting Mapcode Foundation\n");
     printf("\n");
     printf("Usage:\n");
@@ -80,12 +90,16 @@ static void usage(const char* appName) {
     printf("\n");
     printf("    %s [-b | --boundaries]\n", appName);
     printf("    %s [-g | --grid] <nrOfPoints> [<extraDigits>]\n", appName);
-    printf("    %s [-r | --random] <nrOfPoints> [<seed>]\n", appName);
+    printf("    %s [-r | --random] <nrOfPoints> [<extraDigits>] [<seed>]\n", appName);
     printf("\n");
     printf("       Create a test set of lat/lon pairs based on the Mapcode boundaries database\n");
     printf("       as a fixed 3D grid or random uniformly distributed set of lat/lons with their\n");
     printf("       (x, y, z) coordinates and all Mapcode aliases.\n");
     printf("\n");
+    printf("       <extraDigits> specifies additional accuracy, use 0 for standard.\n");
+    printf("       <seed> is an optional random seed, use 0 for arbitrary>.\n");
+    printf("       (You may wish to specify a specific seed to regenerate test cases).\n");
+    printf("\n");
     printf("       The output format is:\n");
     printf("           <number-of-aliases> <lat-deg> <lon-deg> <x> <y> <z>\n");
     printf("           <territory> <mapcode>      (repeated 'number-of-aliases' times)\n");
@@ -100,7 +114,7 @@ static void usage(const char* appName) {
     printf("       The (x, y, z) coordinates are primarily meant for visualization of the data set.\n");
     printf("\n");
     printf("       Notes on the use of stdout and stderr:\n");
-    printf("       stdout: used for outputting 3D point data; stderr: used for statistics.");
+    printf("       stdout: used for outputting 3D point data; stderr: used for statistics.\n");
     printf("       You can redirect stdout to a destination file, while stderr will show progress.\n");
     printf("\n");
     printf("       The result code is 0 when no error occurred, 1 if an input error occurred and 2\n");
@@ -552,7 +566,7 @@ int main(const int argc, const char** argv)
         // Generate grid test set:    [-g | --grid]   <nrOfPoints> [<extradigits>]
         // Generate uniform test set: [-r | --random] <nrOfPoints> [<seed>]
         // ------------------------------------------------------------------
-        if ((argc < 3) || (argc > 4)) {
+        if ((argc < 3) || (argc > 5)) {
             fprintf(stderr, "error: incorrect number of arguments\n\n");
             usage(appName);
             return NORMAL_ERROR;
@@ -565,8 +579,11 @@ int main(const int argc, const char** argv)
         }
         int random = (strcmp(cmd, "-r") == 0) || (strcmp(cmd, "--random") == 0);
         if (random) {
-            if (argc == 4) {
-                const int seed = atoi(argv[3]);
+            if (argc >= 4) {
+                extraDigits = atoi(argv[3]);
+            }
+            if (argc == 5) {
+                const int seed = atoi(argv[4]);
                 srand(seed);
             }
             else {
diff --git a/mapcodelib/basics.h b/mapcodelib/basics.h
index feb90db..47ca841 100644
--- a/mapcodelib/basics.h
+++ b/mapcodelib/basics.h
@@ -1,3 +1,19 @@
+/*
+ * Copyright (C) 2014 Stichting Mapcode Foundation (http://www.mapcode.com)
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
 #define UWORD unsigned short int // 2-byte unsigned integer
 
 #define mapcode_cversion "1.40"
diff --git a/mapcodelib/mapcoder.c b/mapcodelib/mapcoder.c
index 5d8c775..3e9735e 100644
--- a/mapcodelib/mapcoder.c
+++ b/mapcodelib/mapcoder.c
@@ -2348,7 +2348,7 @@ int interpret_coord( const unsigned char *i, int islat, double *result )
   char *p;
   int sign=1;
 
-  while (*i && (p=strchr(winds,*i))!=NULL) { { if ( (p-winds) & 1 ) sign*=-1; } i++; }
+  while (*i && (p=(char*)strchr(winds,*i))!=NULL) { { if ( (p-(char*)winds) & 1 ) sign*=-1; } i++; }
 
   // we are now at a lead digit, or there is an error
   if (!isdig(*i))
@@ -2381,7 +2381,7 @@ int interpret_coord( const unsigned char *i, int islat, double *result )
   }
 
   // allow all posisble final endsigns
-  { while (*i && (p=strchr(winds,*i))!=NULL) { if ( (p-winds) & 1 ) sign*=-1; i++; } }
+  { while (*i && (p=(char*)strchr(winds,*i))!=NULL) { if ( (p-(char*)winds) & 1 ) sign*=-1; i++; } }
 
   // we now MUST be at the end of the string!
   if (*i)
diff --git a/mapcodelib/mapcoder.h b/mapcodelib/mapcoder.h
index 7970e5c..0c3d6c8 100644
--- a/mapcodelib/mapcoder.h
+++ b/mapcodelib/mapcoder.h
@@ -14,7 +14,6 @@
  * limitations under the License.
  */
 
-
 #define RELEASENEAT                         // Use clean code (mapcoder.c).
 #define UWORD           unsigned short int  // 2-byte unsigned integer.
 #define SUPPORT_FOREIGN_ALPHABETS

-- 
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