Skip to content

Commit e2e1536

Browse files
committed
Fixed utility
1 parent 972d10a commit e2e1536

File tree

2 files changed

+27
-19
lines changed

2 files changed

+27
-19
lines changed

README.md

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -65,25 +65,33 @@ decode Mapcodes.
6565

6666
This produces the following help text:
6767

68-
MAPCODE (version 2.2.2)
68+
MAPCODE (version 2.4.0)
6969
Copyright (C) 2014-2015 Stichting Mapcode Foundation
7070

7171
Usage:
72-
mapcode [-d| --decode] <default-territory> <mapcode> [<mapcode> ...]
72+
./mapcode [-d| --decode] <default-territory> <mapcode> [<mapcode> ...]
7373

7474
Decode a mapcode to a lat/lon. The default territory code is used if
7575
the mapcode is a shorthand local code
7676

77-
mapcode [-e[0-8] | --encode[0-8]] <lat:-90..90> <lon:-180..180> [territory]>
77+
./mapcode [-e[0-8] | --encode[0-8]] <lat:-90..90> <lon:-180..180> [territory]>
7878

7979
Encode a lat/lon to a mapcode. If the territory code is specified, the
8080
encoding will only succeeed if the lat/lon is located in the territory.
8181
You can specify the number of additional digits, 0, 1 or 2 (default 0)
8282
for high-precision mapcodes.
8383

84-
mapcode [-b[XYZ] | --boundaries[XYZ]] [<extraDigits>]
85-
mapcode [-g[XYZ] | --grid[XYZ]] <nrOfPoints> [<extraDigits>]
86-
mapcode [-r[XYZ] | --random[XYZ]] <nrOfPoints> [<extraDigits>] [<seed>]
84+
./mapcode [-t | --territories]
85+
86+
Create a full set of territories in CSV format.
87+
88+
./mapcode [-a | --alphabets]
89+
90+
Create a full set of alphabet tests in CSV format.
91+
92+
./mapcode [-b[XYZ] | --boundaries[XYZ]] [<extraDigits>]
93+
./mapcode [-g[XYZ] | --grid[XYZ]] <nrOfPoints> [<extraDigits>]
94+
./mapcode [-r[XYZ] | --random[XYZ]] <nrOfPoints> [<extraDigits>] [<seed>]
8795

8896
Create a test set of lat/lon pairs based on the mapcode boundaries database
8997
as a fixed 3D grid or random uniformly distributed set of lat/lons with their
@@ -107,8 +115,8 @@ This produces the following help text:
107115
The (x, y, z) coordinates are primarily meant for visualization of the data set.
108116

109117
Example:
110-
mapcode -g 100 : produces a grid of 100 points as lat/lon pairs
111-
mapcode -gXYZ 100 : produces a grid of 100 points as (x, y, z) sphere coordinates)
118+
./mapcode -g 100 : produces a grid of 100 points as lat/lon pairs
119+
./mapcode -gXYZ 100 : produces a grid of 100 points as (x, y, z) sphere coordinates)
112120

113121
Notes on the use of stdout and stderr:
114122
stdout: used for outputting 3D point data; stderr: used for statistics.

utility/mapcode.cpp

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -700,20 +700,20 @@ int main(const int argc, const char **argv) {
700700
for (variant = 0; variant <= 2; variant++) {
701701
int m;
702702
for (m = 0; mapcodeForCSV[m] != NULL; m++) {
703-
char str[128];
704-
char recoded[128];
705-
UWORD unibuf[128];
703+
char asciiString[128];
704+
char aciiStringRecoded[128];
705+
UWORD utf16String[128];
706706
// build a mapcode variant
707-
char mc[128];
708-
strcpy(mc, mapcodeForCSV[m]);
709-
strcat(mc, (variant == 1) ? "-bc" : (variant == 2) ? "-DFGHJKLM" : "");
707+
char mapcode[128];
708+
strcpy(mapcode, mapcodeForCSV[m]);
709+
strcat(mapcode, (variant == 1) ? "-bc" : (variant == 2) ? "-DFGHJKLM" : "");
710710
// convert to alphabet, and back to roman
711-
convertToAlphabet(unibuf, 128, mc, alphabet);
712-
convertToRoman(recoded, 128, unibuf);
711+
convertToAlphabet(utf16String, 128, mapcode, alphabet);
712+
convertToRoman(aciiStringRecoded, 128, utf16String);
713713
// output a line of csv (in utf8 format)
714-
convertUtf16ToUtf8(str, unibuf);
715-
printf("%d,%s,%s,%s\n", alphabet, mc, str, recoded);
716-
if (stricmp(mc, recoded) != 0) {
714+
convertUtf16ToUtf8(asciiString, utf16String);
715+
printf("%d,%s,%s,%s\n", alphabet, mapcode, asciiString, aciiStringRecoded);
716+
if (strcmp(mapcode, aciiStringRecoded) != 0) {
717717
fprintf(stderr, "error: utility produces unexpected results\n\n");
718718
return NORMAL_ERROR;
719719
}

0 commit comments

Comments
 (0)