Skip to content

Commit 1d51e8e

Browse files
committed
Added locales, fixed 5.5 bug
2 parents 3f30d18 + 4a3620d commit 1d51e8e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+12704
-544
lines changed

.gitignore

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
unittest/gmon.out
2-
unittest/_*.txt
3-
unittest/*.gcov
4-
unittest/*.gcda
5-
unittest/*.gcno
1+
test/gmon.out
2+
test/_*.txt
3+
test/*.gcov
4+
test/*.gcda
5+
test/*.gcno
66
mapcodelib/*.gcov
77
mapcodelib/*.gcda
88
mapcodelib/*.gcno
@@ -13,8 +13,10 @@ cmake_install.cmake
1313
*.a
1414
unittest
1515
mapcode
16-
unittest/unittest
16+
test/unittest
1717
utility/mapcode
18+
cmake-build-debug/
19+
*.cbp
1820

1921
# -----------------------------------------------------------------------------
2022
# Compiled sources

CMakeLists.txt

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ project(mapcode_cpp)
2727
# NO_FAST_ENCODE - Drop fast encoding support - only for internal use.
2828

2929
set(MAPCODE_OPTIONS "")
30-
set(MAPCODE_WARNING_OPTIONS "-Wall -Werror -Wextra -Wpedantic")
30+
set(MAPCODE_WARNING_OPTIONS "-Wall -Werror -Wextra")
3131
set(MAPCODE_SANITIZER_COMPILER_OPTIONS "-fsanitize=address -fno-common -fno-optimize-sibling-calls -fno-omit-frame-pointer")
3232
set(MAPCODE_SANITIZER_LINKER_OPTIONS "-fsanitize=address")
3333

@@ -48,13 +48,34 @@ set(SOURCE_FILES_MAPCODELIB
4848
mapcodelib/internal_alphabet_recognizer.h
4949
mapcodelib/internal_iso3166_data.h
5050
mapcodelib/internal_territory_alphabets.h
51+
mapcodelib/internal_territory_names_af.h
52+
mapcodelib/internal_territory_names_ar.h
53+
mapcodelib/internal_territory_names_be.h
54+
mapcodelib/internal_territory_names_cn.h
55+
mapcodelib/internal_territory_names_cs.h
5156
mapcodelib/internal_territory_names_da.h
5257
mapcodelib/internal_territory_names_de.h
5358
mapcodelib/internal_territory_names_en.h
59+
mapcodelib/internal_territory_names_es.h
60+
mapcodelib/internal_territory_names_fi.h
5461
mapcodelib/internal_territory_names_fr.h
62+
mapcodelib/internal_territory_names_he.h
5563
mapcodelib/internal_territory_names_hi.h
56-
mapcodelib/internal_territory_names_nl.h
64+
mapcodelib/internal_territory_names_hr.h
65+
mapcodelib/internal_territory_names_id.h
66+
mapcodelib/internal_territory_names_it.h
67+
mapcodelib/internal_territory_names_ja.h
68+
mapcodelib/internal_territory_names_ko.h
5769
mapcodelib/internal_territory_names_local.h
70+
mapcodelib/internal_territory_names_nl.h
71+
mapcodelib/internal_territory_names_no.h
72+
mapcodelib/internal_territory_names_pl.h
73+
mapcodelib/internal_territory_names_pt.h
74+
mapcodelib/internal_territory_names_ru.h
75+
mapcodelib/internal_territory_names_sv.h
76+
mapcodelib/internal_territory_names_sw.h
77+
mapcodelib/internal_territory_names_tr.h
78+
mapcodelib/internal_territory_names_uk.h
5879
mapcodelib/internal_territory_search.h
5980
mapcodelib/mapcode_alphabets.h
6081
mapcodelib/mapcode_legacy.c
@@ -70,11 +91,23 @@ set(SOURCE_FILES_TEST
7091
set(SOURCE_FILES_UTILITY
7192
utility/mapcode.cpp)
7293

94+
set(THREADS_PREFER_PTHREAD_FLAG ON)
95+
find_package(Threads REQUIRED)
96+
find_library(M_LIB m)
97+
7398
add_library(mapcodelib ${SOURCE_FILES_MAPCODELIB})
7499
target_include_directories(mapcodelib PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
100+
target_link_libraries(mapcodelib Threads::Threads)
101+
target_link_libraries(mapcodelib ${M_LIB})
75102

76103
add_executable(unittest ${SOURCE_FILES_TEST})
77104
target_link_libraries(unittest LINK_PUBLIC mapcodelib)
105+
target_link_libraries(unittest LINK_PUBLIC Threads::Threads)
106+
target_link_libraries(unittest LINK_PUBLIC ${M_LIB})
78107

79108
add_executable(mapcode ${SOURCE_FILES_UTILITY})
80109
target_link_libraries(mapcode LINK_PUBLIC mapcodelib)
110+
target_link_libraries(mapcode LINK_PUBLIC Threads::Threads)
111+
target_link_libraries(mapcode LINK_PUBLIC ${M_LIB})
112+
113+
install(TARGETS mapcode DESTINATION /usr/local/bin)

README.md

Lines changed: 77 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -15,35 +15,34 @@ The directory 'mapcodelib' contains the files:
1515

1616
mapcodelib/
1717
mapcoder.h <-- Header file with method prototypes and defines for caller.
18-
mapcoder.c
19-
basics.h
18+
mapcoder.c <-- Implementation of mapcode routines.
19+
internal_*.h <-- Internal implementataion details for library.
2020

21-
mapcode_fastencode.h <-- include unless FAST_ENCODE is undefined
22-
mapcode_fastalpha.h <-- needed only if FAST_ALPHA is defined
23-
24-
mapcode_countrynames.h <-- optional array with english territory names, including official names
25-
mapcode_countrynames_short.h <-- optional array with english territory names
21+
mapcode_alphabets.h <-- Enumeration of supported alphabets (or scripts).
22+
mapcode_territories.h <-- Enumeration of supported territories.
23+
24+
mapcode_legacy.h <-- Courtesy support for legacy calls, may be deprecated in future.
2625

2726
Together these provide routine to encode/decode Mapcodes.
2827

2928
Documentation, including example snippets of C source code, can be found in
3029

3130
docs/
3231
mapcode_library_c.pdf <-- PDF format.
33-
mapcode_library_c.doc <-- Microsoft Word format.
32+
mapcode_library_c.docx <-- Microsoft Word format.
3433

35-
A unit test can be found in the `test` subdirectory.
36-
Compile and run `unittest.c` to see if the library performs as expected.
37-
Check the `README.md` file in `test` to see how you can compile it/
34+
A unit test can be found in the `test` subdirectory. Compile and run `unittest.c` to see
35+
if the library performs as expected:
3836

39-
Also see www.mapcode.com for background and reference materials.
37+
cd mapcodelib
38+
gcc -O -c mapcoder.c
39+
cd ../test
40+
gcc -O unittest.c -lm -lpthread -o unittest ../mapcodelib/mapcoder.o
41+
./unittest
4042

41-
Note: this version may be restricted to a particular area of the Earth!
42-
In that case, basics.h will state a version number of the for:
43+
Check the `README.md` in directory `test` for more information.
4344

44-
#define mapcode_cversion "1.2xxx"
45-
46-
where "xxx" states the geographical limitation.
45+
Also see http://www.mapcode.com for background and reference materials.
4746

4847

4948
## A Real-Life Example, The 'mapcode' Codec Tool: `utility/`
@@ -53,8 +52,10 @@ of how to use the library.
5352

5453
To build the original Mapcode tool, execute:
5554

56-
cd utility
57-
gcc -O mapcode.cpp -o mapcode
55+
cd mapcodelib
56+
gcc -O -c mapcoder.c
57+
cd ../utility
58+
gcc -O mapcode.cpp -o mapcode ../mapcodelib/mapcoder.o
5859

5960
For help, simply execute the binary file 'mapcode' without no arguments.
6061
This tool provides a rather extensive command-line interface to encode and
@@ -66,29 +67,29 @@ This produces the following help text:
6667
Copyright (C) 2014-2016 Stichting Mapcode Foundation
6768

6869
Usage:
69-
./mapcode [-d| --decode] <default-territory> <mapcode> [<mapcode> ...]
70+
mapcode [-d| --decode] <default-territory> <mapcode> [<mapcode> ...]
7071

7172
Decode a mapcode to a lat/lon. The default territory code is used if
7273
the mapcode is a shorthand local code
7374

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

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

81-
./mapcode [-t | --territories]
82+
mapcode [-t | --territories]
8283

8384
Create a full set of territories in CSV format.
8485

85-
./mapcode [-a | --alphabets]
86+
mapcode [-a | --alphabets]
8687

8788
Create a full set of alphabet tests in CSV format.
8889

89-
./mapcode [-b[XYZ] | --boundaries[XYZ]] [<extraDigits>]
90-
./mapcode [-g[XYZ] | --grid[XYZ]] <nrOfPoints> [<extraDigits>]
91-
./mapcode [-r[XYZ] | --random[XYZ]] <nrOfPoints> [<extraDigits>] [<seed>]
90+
mapcode [-b[XYZ] | --boundaries[XYZ]] [<extraDigits>]
91+
mapcode [-g[XYZ] | --grid[XYZ]] <nrOfPoints> [<extraDigits>]
92+
mapcode [-r[XYZ] | --random[XYZ]] <nrOfPoints> [<extraDigits>] [<seed>]
9293

9394
Create a test set of lat/lon pairs based on the mapcode boundaries database
9495
as a fixed 3D grid or random uniformly distributed set of lat/lons with their
@@ -112,16 +113,16 @@ This produces the following help text:
112113
The (x, y, z) coordinates are primarily meant for visualization of the data set.
113114

114115
Example:
115-
./mapcode -g 100 : produces a grid of 100 points as lat/lon pairs
116-
./mapcode -gXYZ 100 : produces a grid of 100 points as (x, y, z) sphere coordinates)
116+
mapcode -g 100 : produces a grid of 100 points as lat/lon pairs
117+
mapcode -gXYZ 100 : produces a grid of 100 points as (x, y, z) sphere coordinates)
117118

118119
Notes on the use of stdout and stderr:
119-
stdout: used for outputting 3D point data; stderr: used for statistics.
120+
stdout: used for outputting 3D Point data; stderr: used for statistics.
120121
You can redirect stdout to a destination file, while stderr will show progress.
121122

122123
The result code is 0 when no error occurred, 1 if an input error occurred and 2
123124
if an internal error occurred.
124-
125+
125126
## Compile Options for Microsoft Visual C++
126127

127128
If you use **Microsoft Visual C++**, you may need to add the following compiler directives to your build:
@@ -136,11 +137,56 @@ The Mapcode C/C++ Library has includes a number of fixed data tables, which incr
136137
You may not require all of this data, so we've added some options for you to be able to reduce its
137138
footprint, for example for embedded applications.
138139

140+
You can specify the define `MAPCODE_NO_SUPPORT_ALL_LANGUAGES` to disable support for territory names
141+
in all languages.
142+
143+
Note that English names are always supported and it's also always possible to get territory names
144+
in their locale language.
145+
146+
To add individual support support for other languages (of all territory names), use:
147+
148+
-DMAPCODE_NO_SUPPORT_ALL_LANGUAGES // If not defined, ALL languages are available.
149+
-DMAPCODE_SUPPORT_LANGUAGE_AF // Add the languages you need. The names are the
150+
-DMAPCODE_SUPPORT_LANGUAGE_AR // ISO 3166-2 character codes.
151+
-DMAPCODE_SUPPORT_LANGUAGE_BE
152+
-DMAPCODE_SUPPORT_LANGUAGE_CN
153+
-DMAPCODE_SUPPORT_LANGUAGE_CS
154+
-DMAPCODE_SUPPORT_LANGUAGE_DA
155+
-DMAPCODE_SUPPORT_LANGUAGE_DE
156+
-DMAPCODE_SUPPORT_LANGUAGE_EN
157+
-DMAPCODE_SUPPORT_LANGUAGE_ES
158+
-DMAPCODE_SUPPORT_LANGUAGE_FI
159+
-DMAPCODE_SUPPORT_LANGUAGE_FR
160+
-DMAPCODE_SUPPORT_LANGUAGE_HE
161+
-DMAPCODE_SUPPORT_LANGUAGE_HI
162+
-DMAPCODE_SUPPORT_LANGUAGE_HR
163+
-DMAPCODE_SUPPORT_LANGUAGE_ID
164+
-DMAPCODE_SUPPORT_LANGUAGE_IT
165+
-DMAPCODE_SUPPORT_LANGUAGE_JA
166+
-DMAPCODE_SUPPORT_LANGUAGE_KO
167+
-DMAPCODE_SUPPORT_LANGUAGE_NL
168+
-DMAPCODE_SUPPORT_LANGUAGE_NO
169+
-DMAPCODE_SUPPORT_LANGUAGE_PL
170+
-DMAPCODE_SUPPORT_LANGUAGE_PT
171+
-DMAPCODE_SUPPORT_LANGUAGE_RU
172+
-DMAPCODE_SUPPORT_LANGUAGE_SV
173+
-DMAPCODE_SUPPORT_LANGUAGE_SW
174+
-DMAPCODE_SUPPORT_LANGUAGE_TR
175+
-DMAPCODE_SUPPORT_LANGUAGE_UK
176+
177+
The list of support languages may grow over time.
178+
139179
## Release Notes
140180

141181
### 2.5.2
142182

143-
* Added locale support.
183+
* Added unit test for floating point error with code "40822.schol".
184+
185+
* Added locale support.
186+
187+
* Added many languages.
188+
189+
* Hardened unit tests.
144190

145191
### 2.5.1
146192

docs/mapcode_library_c.docx

-1.24 KB
Binary file not shown.

0 commit comments

Comments
 (0)