1- /* *
2- * Copyright (C) 2014 Stichting Mapcode Foundation
3- * For terms of use refer to http://www.mapcode.com/downloads.html
1+ /*
2+ * Copyright (C) 2014 Stichting Mapcode Foundation (http://www.mapcode.com)
3+ *
4+ * Licensed under the Apache License, Version 2.0 (the "License");
5+ * you may not use this file except in compliance with the License.
6+ * You may obtain a copy of the License at
7+ *
8+ * http://www.apache.org/licenses/LICENSE-2.0
9+ *
10+ * Unless required by applicable law or agreed to in writing, software
11+ * distributed under the License is distributed on an "AS IS" BASIS,
12+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+ * See the License for the specific language governing permissions and
14+ * limitations under the License.
415 */
516
617/* *
3142#define my_isnan (x ) (false )
3243#define my_round (x ) ((long ) (floor((x) + 0.5 )))
3344
34- static const char * VERSION = " 1" ;
3545static const int SELF_CHECK = 1 ;
3646static const int SELF_CHECK_EXIT = 0 ;
3747
@@ -64,7 +74,7 @@ static double lonLargestNrOfResults = 0.0;
6474 * whenever a incorrect amount or combination of parameters is entered.
6575 */
6676static void usage (const char * appName) {
67- printf (" MAPCODE (version %s.%s%s )\n " , mapcode_cversion, VERSION , SELF_CHECK ? " , self-checking" : " " );
77+ printf (" MAPCODE (version %s%s )\n " , mapcode_cversion, SELF_CHECK ? " , self-checking" : " " );
6878 printf (" Copyright (C) 2014 Stichting Mapcode Foundation\n " );
6979 printf (" \n " );
7080 printf (" Usage:\n " );
@@ -80,12 +90,16 @@ static void usage(const char* appName) {
8090 printf (" \n " );
8191 printf (" %s [-b | --boundaries]\n " , appName);
8292 printf (" %s [-g | --grid] <nrOfPoints> [<extraDigits>]\n " , appName);
83- printf (" %s [-r | --random] <nrOfPoints> [<seed>]\n " , appName);
93+ printf (" %s [-r | --random] <nrOfPoints> [<extraDigits>] [< seed>]\n " , appName);
8494 printf (" \n " );
8595 printf (" Create a test set of lat/lon pairs based on the Mapcode boundaries database\n " );
8696 printf (" as a fixed 3D grid or random uniformly distributed set of lat/lons with their\n " );
8797 printf (" (x, y, z) coordinates and all Mapcode aliases.\n " );
8898 printf (" \n " );
99+ printf (" <extraDigits> specifies additional accuracy, use 0 for standard.\n " );
100+ printf (" <seed> is an optional random seed, use 0 for arbitrary>.\n " );
101+ printf (" (You may wish to specify a specific seed to regenerate test cases).\n " );
102+ printf (" \n " );
89103 printf (" The output format is:\n " );
90104 printf (" <number-of-aliases> <lat-deg> <lon-deg> <x> <y> <z>\n " );
91105 printf (" <territory> <mapcode> (repeated 'number-of-aliases' times)\n " );
@@ -100,7 +114,7 @@ static void usage(const char* appName) {
100114 printf (" The (x, y, z) coordinates are primarily meant for visualization of the data set.\n " );
101115 printf (" \n " );
102116 printf (" Notes on the use of stdout and stderr:\n " );
103- printf (" stdout: used for outputting 3D point data; stderr: used for statistics." );
117+ printf (" stdout: used for outputting 3D point data; stderr: used for statistics.\n " );
104118 printf (" You can redirect stdout to a destination file, while stderr will show progress.\n " );
105119 printf (" \n " );
106120 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)
552566 // Generate grid test set: [-g | --grid] <nrOfPoints> [<extradigits>]
553567 // Generate uniform test set: [-r | --random] <nrOfPoints> [<seed>]
554568 // ------------------------------------------------------------------
555- if ((argc < 3 ) || (argc > 4 )) {
569+ if ((argc < 3 ) || (argc > 5 )) {
556570 fprintf (stderr, " error: incorrect number of arguments\n\n " );
557571 usage (appName);
558572 return NORMAL_ERROR;
@@ -565,8 +579,11 @@ int main(const int argc, const char** argv)
565579 }
566580 int random = (strcmp (cmd, " -r" ) == 0 ) || (strcmp (cmd, " --random" ) == 0 );
567581 if (random) {
568- if (argc == 4 ) {
569- const int seed = atoi (argv[3 ]);
582+ if (argc >= 4 ) {
583+ extraDigits = atoi (argv[3 ]);
584+ }
585+ if (argc == 5 ) {
586+ const int seed = atoi (argv[4 ]);
570587 srand (seed);
571588 }
572589 else {
0 commit comments