Skip to content

Commit 914d8db

Browse files
committed
Merged
1 parent a450ba0 commit 914d8db

File tree

11 files changed

+198
-179
lines changed

11 files changed

+198
-179
lines changed

CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ set(SOURCE_FILES
99
mapcodelib/mapcode_countrynames_short.h
1010
mapcodelib/mapcode_fast_encode.h
1111
mapcodelib/mapcode_fastalpha.h
12+
mapcodelib/mapcode_territory_alphabets.h
1213
mapcodelib/mapcoder.c
1314
mapcodelib/mapcoder.h
1415
unittest/decode_test.h

README.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -124,11 +124,13 @@ This produces the following help text:
124124
* Added scripts for Korean (Choson'gul / Hangul), Burmese, Khmer, Sinhalese, Thaana (Maldivan),
125125
Chinese (Zhuyin, Bopomofo), Tifinagh (Berber), Tamil, Amharic, Telugu, Odia, Kannada, Gujarati.
126126

127-
* Renamed constants to more correct terms (Malay to Malayalam; Hindi to Devanagari).
127+
* Renamed constants to more correct terms (Malay to Malayalam, Hindi to Devanagari).
128128

129-
* Added getAlphabetsForTerritory(t), returning the most commonly used alphabets for territory t.
129+
* Added `getAlphabetsForTerritory(t)`, returning the most commonly used alphabets for territory `t`.
130130

131-
* Improved some characters for Arabic and Devanagari; Fixed Bengali to also support Assamese.
131+
* Improved some characters for Arabic and Devanagari.
132+
133+
* Fixed Bengali to also support Assamese.
132134

133135
### 2.3.1
134136

mapcodelib/mapcode_alphabets.h

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
/*
2+
* Copyright (C) 2014-2015 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.
15+
*/
16+
#ifndef __MAPCODE_ALPHABETS_H__
17+
#define __MAPCODE_ALPHABETS_H__
18+
19+
20+
#ifdef __cplusplus
21+
extern "C" {
22+
#endif
23+
24+
/**
25+
* Alphabets:
26+
*/
27+
#define MAPCODE_ALPHABETS_TOTAL 28
28+
29+
#define MAPCODE_ALPHABET_ROMAN 0
30+
#define MAPCODE_ALPHABET_GREEK 1
31+
#define MAPCODE_ALPHABET_CYRILLIC 2
32+
#define MAPCODE_ALPHABET_HEBREW 3
33+
#define MAPCODE_ALPHABET_DEVANAGARI 4
34+
#define MAPCODE_ALPHABET_MALAYALAM 5
35+
#define MAPCODE_ALPHABET_GEORGIAN 6
36+
#define MAPCODE_ALPHABET_KATAKANA 7
37+
#define MAPCODE_ALPHABET_THAI 8
38+
#define MAPCODE_ALPHABET_LAO 9
39+
#define MAPCODE_ALPHABET_ARMENIAN 10
40+
#define MAPCODE_ALPHABET_BENGALI 11
41+
#define MAPCODE_ALPHABET_GURMUKHI 12
42+
#define MAPCODE_ALPHABET_TIBETAN 13
43+
#define MAPCODE_ALPHABET_ARABIC 14
44+
#define MAPCODE_ALPHABET_KOREAN 15
45+
#define MAPCODE_ALPHABET_BURMESE 16
46+
#define MAPCODE_ALPHABET_KHMER 17
47+
#define MAPCODE_ALPHABET_SINHALESE 18
48+
#define MAPCODE_ALPHABET_THAANA 19
49+
#define MAPCODE_ALPHABET_CHINESE 20
50+
#define MAPCODE_ALPHABET_TIFINAGH 21
51+
#define MAPCODE_ALPHABET_TAMIL 22
52+
#define MAPCODE_ALPHABET_AMHARIC 23
53+
#define MAPCODE_ALPHABET_TELUGU 24
54+
#define MAPCODE_ALPHABET_ODIA 25
55+
#define MAPCODE_ALPHABET_KANNADA 26
56+
#define MAPCODE_ALPHABET_GUJARATI 27
57+
58+
#define MAX_ALPHABETS_PER_TERRITORY 3
59+
typedef struct {
60+
int count;
61+
int alphabet[MAX_ALPHABETS_PER_TERRITORY];
62+
} TerritoryAlphabets;
63+
64+
#ifdef __cplusplus
65+
}
66+
#endif
67+
68+
#endif // __MAPCODE_ALPHABETS_H__
69+

mapcodelib/mapcode_countrynames.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
#define __MAPCODE_COUNTRYNAMES_H__
1818

1919
// *** GENERATED FILE (coords.cpp), DO NOT CHANGE OR PRETTIFY ***
20-
const char *isofullname[] = {
20+
static const char *isofullname[] = {
2121
"Vatican City State (Holy See)",
2222
"Monaco (Principality of _)",
2323
"Gibraltar",

mapcodelib/mapcode_countrynames_short.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
#define __MAPCODE_COUNTRYNAMES_H__
1818

1919
// *** GENERATED FILE (coords.cpp), DO NOT CHANGE OR PRETTIFY ***
20-
const char *isofullname[] = {
20+
static const char *isofullname[] = {
2121
"Vatican City State (Holy See)",
2222
"Monaco",
2323
"Gibraltar",

mapcodelib/mapcode_territory_alphabets.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,9 @@ extern "C" {
2424
#endif
2525

2626
#include "basics.h"
27+
#include "mapcode_alphabets.h"
2728

28-
#include "mapcoder.h"
29-
30-
TerritoryAlphabets alphabetsForTerritory[MAX_CCODE] = {
29+
static const TerritoryAlphabets alphabetsForTerritory[MAX_CCODE] = {
3130
{1, {MAPCODE_ALPHABET_ROMAN}}, // 0 VAT Vatican City State
3231
{1, {MAPCODE_ALPHABET_ROMAN}}, // 1 MCO Monaco
3332
{1, {MAPCODE_ALPHABET_ROMAN}}, // 2 GIB Gibraltar

mapcodelib/mapcoder.c

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1796,7 +1796,7 @@ static struct {
17961796
{0x0e01, 0x0e32, "BC?D??FGHJ??O???K??L?MNP?Q?R????S?T?V?W????UXYZAIE"}, // Thai
17971797
{0x0e81, 0x0ec6, "BC?D??FG?H??J??????K??L?MN?P?Q??RST???V??WX?Y?ZA????????????U?????EI?O"}, // Lao
17981798
{0x0532, 0x0556, "BCDE??FGHI?J?KLM?N?U?PQ?R??STVWXYZ?OA"}, // Armenian
1799-
{0x0995, 0x09b9, "CDFBGH?AJOUKLMNPQR?S?TIVWEX??Y??????Z" }, // Bengali/Assamese
1799+
{0x0995, 0x09b9, "CDFBGH?AJOUKLMNPQR?S?TIVWEX??Y??????Z"}, // Bengali/Assamese
18001800
{0x0a05, 0x0a39, "A?????????E?????B?CD?F?G??HJZ?KL?MNP?QU?RS?T?V??W??XY"}, // Gurmukhi
18011801
{0x0f40, 0x0f66, "BCD?FGHJ?K?????NMP?QRLS?A?????TVUWXYE?Z"}, // Tibetan
18021802
{0x0627, 0x0648, "IA?BEVCDFGHJKLMNPQRS??????TU?WXYOZ"}, // Arabic
@@ -1811,20 +1811,20 @@ static struct {
18111811
{0x17e0, 0x17e9, ""}, // Khmer digits
18121812
{0x0be6, 0x0bef, ""}, // Tamil digits
18131813
{0x1369, 0x1372, "1234567890"}, // Amharic digits [1-9][0]
1814-
1814+
18151815
{0x1100, 0x1175, "B?CD?F?G?H?OV?WXJKA??????????????????????????????????????????????????????????????????????????????LMNPQER?S???YZ???T?UI"}, // Korean
18161816
{0x1000, 0x101f, "BCDFGA?J????KLMYNPQESTUWX?HIZORV"}, // Burmese
18171817
{0x1780, 0x17a2, "BCDFGE?HJAK?LMN??PQRSTV?W?IXO??UY?Z"}, // Khmer
18181818
{0x0d85, 0x0dc5, "A???E?U??????????????B?C??D??F????G?H??JK?L?M?NP?Q?RSTV?W??X?IYZO"}, // Sinhalese
18191819
{0x0780, 0x07b1, "BCDFGHJKLMNPQRSTVWXYA?OE????U???????I????????????Z"}, // Thaana
18201820
{0x3105, 0x3129, "BDFCGHJKLMNRSTUEPQWYZ????I?O??A????XV"}, // Chinese
1821-
{0x2d31, 0x2d63, "B?C???D????FG??H??JKL?M?A???NPI???EOQR??STVW??X?YUZ" }, // Tifinagh
1822-
{0x0b85, 0x0bb5, "SE?TV????WXY?ZU?B???AC???OD????F???GIH???JKLRMQPN" }, // Tamil
1823-
{0x1200, 0x1354, "H???????L??????????????????A??E?T?????V?????S???????????????????Q???R???????????????????????????B???C???????????W?????X????????????????????????????M????????????I???????????K???????????????????????????U???????O???????????Z???????????J???????D???????????????????????G???????????????????????????????????????????????Y?????????????????F?????N???P" }, // Amharic
1824-
{0x0c15, 0x0c35, "BOC?DFIG?AHJK?LMNPQR?SETUV?W?XY?Z" }, // Telugu
1825-
{0x0b15, 0x0b39, "BCDF?G?HA?JOKLEMNPQR?SIT?VWX??Y????ZU" }, // Odia
1826-
{0x0c85, 0x0cb5, "I?U?O????E???A??BCD?FGHJ???KL?MN?PQR?STVW??X?Y??Z" }, // Kannada
1827-
{0x0a87, 0x0ab7, "E?U???O?I?????H?B??J?CXRKNDY?L?F?W?MTGZS?P??A?Q?V" }, // Gujarati
1821+
{0x2d31, 0x2d63, "B?C???D????FG??H??JKL?M?A???NPI???EOQR??STVW??X?YUZ"}, // Tifinagh
1822+
{0x0b85, 0x0bb5, "SE?TV????WXY?ZU?B???AC???OD????F???GIH???JKLRMQPN"}, // Tamil
1823+
{0x1200, 0x1354, "H???????L??????????????????A??E?T?????V?????S???????????????????Q???R???????????????????????????B???C???????????W?????X????????????????????????????M????????????I???????????K???????????????????????????U???????O???????????Z???????????J???????D???????????????????????G???????????????????????????????????????????????Y?????????????????F?????N???P"}, // Amharic
1824+
{0x0c15, 0x0c35, "BOC?DFIG?AHJK?LMNPQR?SETUV?W?XY?Z"}, // Telugu
1825+
{0x0b15, 0x0b39, "BCDF?G?HA?JOKLEMNPQR?SIT?VWX??Y????ZU"}, // Odia
1826+
{0x0c85, 0x0cb5, "I?U?O????E???A??BCD?FGHJ???KL?MN?PQR?STVW??X?Y??Z"}, // Kannada
1827+
{0x0a87, 0x0ab7, "E?U???O?I?????H?B??J?CXRKNDY?L?F?W?MTGZS?P??A?Q?V"}, // Gujarati
18281828

18291829
// lowercase variants: greek, georgisch
18301830
{0x03AD, 0x03c9, "EU??ABGDFZHQIKLMNCOJP?STYVXRW"}, // Greek lowercase
@@ -1906,7 +1906,7 @@ static UWORD *encode_utf16(UWORD *unibuf, const int maxlen, const char *mapcode,
19061906
if ((c < ' ') || (c > 'Z')) { // not in any valid range?
19071907
*w++ = '?';
19081908
} else if ((c >= '0') && (c <= '9')) { // digit?
1909-
*w++ = asc2lan[language][26 + (int)c - '0'];
1909+
*w++ = asc2lan[language][26 + (int) c - '0'];
19101910
} else if (c < 'A') { // valid but not a letter (e.g. a dot, a space...)
19111911
*w++ = (UWORD) c; // leave untranslated
19121912
} else {
@@ -2555,7 +2555,7 @@ static void convertFromAbjad(char *s) {
25552555
int len, dot, form, c;
25562556
char *postfix = strchr(s, '-');
25572557
dot = (int) (strchr(s, '.') - s);
2558-
if (dot<2 || dot>5) {
2558+
if (dot < 2 || dot > 5) {
25592559
return;
25602560
}
25612561
if (postfix) {
@@ -2673,7 +2673,6 @@ static void convertFromAbjad(char *s) {
26732673
}
26742674

26752675

2676-
26772676
const TerritoryAlphabets *getAlphabetsForTerritory(int territoryCode) {
26782677
const int ccode = territoryCode - 1;
26792678
if ((ccode >= 0) && (ccode <= ccode_earth)) { // valid territory, not earth

mapcodelib/mapcoder.h

Lines changed: 4 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@
2121
extern "C" {
2222
#endif
2323

24+
#include "mapcode_alphabets.h"
25+
#include "mapcode_territory_alphabets.h"
26+
2427
#define mapcode_cversion "2.4.0"
2528

2629
#define UWORD unsigned short int // 2-byte unsigned integer.
@@ -36,6 +39,7 @@ extern "C" {
3639
#define MAX_CLEAN_MAPCODE_LEN (MAX_PROPER_MAPCODE_LEN + 1 + MAX_PRECISION_DIGITS) // Max. number of characters in a clean mapcode (excluding zero-terminator).
3740
#define MAX_MAPCODE_RESULT_LEN (MAX_ISOCODE_LEN + 1 + MAX_CLEAN_MAPCODE_LEN + 1) // Max. number of characters to store a single result (including zero-terminator).
3841

42+
3943
/**
4044
* The type Mapcodes hold a number of mapcodes, for example from an encoding call.
4145
* If a result contains a space, it splits the territory alphacode from the mapcode.
@@ -263,48 +267,6 @@ int multipleBordersNearby(
263267
double lon,
264268
int territoryCode);
265269

266-
/**
267-
* Alphabets:
268-
*/
269-
#define MAPCODE_ALPHABETS_TOTAL 28
270-
271-
#define MAPCODE_ALPHABET_ROMAN 0
272-
#define MAPCODE_ALPHABET_GREEK 1
273-
#define MAPCODE_ALPHABET_CYRILLIC 2
274-
#define MAPCODE_ALPHABET_HEBREW 3
275-
#define MAPCODE_ALPHABET_DEVANAGARI 4
276-
#define MAPCODE_ALPHABET_MALAYALAM 5
277-
#define MAPCODE_ALPHABET_GEORGIAN 6
278-
#define MAPCODE_ALPHABET_KATAKANA 7
279-
#define MAPCODE_ALPHABET_THAI 8
280-
#define MAPCODE_ALPHABET_LAO 9
281-
#define MAPCODE_ALPHABET_ARMENIAN 10
282-
#define MAPCODE_ALPHABET_BENGALI 11
283-
#define MAPCODE_ALPHABET_GURMUKHI 12
284-
#define MAPCODE_ALPHABET_TIBETAN 13
285-
#define MAPCODE_ALPHABET_ARABIC 14
286-
#define MAPCODE_ALPHABET_KOREAN 15
287-
#define MAPCODE_ALPHABET_BURMESE 16
288-
#define MAPCODE_ALPHABET_KHMER 17
289-
#define MAPCODE_ALPHABET_SINHALESE 18
290-
#define MAPCODE_ALPHABET_THAANA 19
291-
#define MAPCODE_ALPHABET_CHINESE 20
292-
#define MAPCODE_ALPHABET_TIFINAGH 21
293-
#define MAPCODE_ALPHABET_TAMIL 22
294-
#define MAPCODE_ALPHABET_AMHARIC 23
295-
#define MAPCODE_ALPHABET_TELUGU 24
296-
#define MAPCODE_ALPHABET_ODIA 25
297-
#define MAPCODE_ALPHABET_KANNADA 26
298-
#define MAPCODE_ALPHABET_GUJARATI 27
299-
300-
#define MAX_ALPHABETS_PER_TERRITORY 3
301-
typedef struct {
302-
int count;
303-
int alphabet[MAX_ALPHABETS_PER_TERRITORY];
304-
} TerritoryAlphabets;
305-
306-
#include "mapcode_territory_alphabets.h"
307-
308270
/**
309271
* Given a territory code, returns a structure defining which alphabets (in order of importance) are in common use in the territory
310272
*

unittest/territories.csv

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
ccode,territorycodes(pipe-separated),alphabets(pipe-seperated),names(pipe-separated)
2-
0,VAT,0,Vatican|Holy See
2+
0,VAT,0,Vatican City State|Holy See
33
1,MCO,0,Monaco
44
2,GIB,0,Gibraltar
55
3,TKL,0,Tokelau
@@ -11,7 +11,7 @@ ccode,territorycodes(pipe-separated),alphabets(pipe-seperated),names(pipe-separa
1111
9,SXM,0,Sint Maarten
1212
10,MAF,0,Saint Martin
1313
11,NFK|AU-NF|NF,0,Norfolk and Philip Island|Philip Island
14-
12,PCN,0,Pitcairn Islands
14+
12,PCN,0,Pitcairn Group of Islands
1515
13,BVT,0,Bouvet Island
1616
14,BMU,0,Bermuda|Somers Isles
1717
15,IOT|DGA,0,British Indian Ocean Territory

0 commit comments

Comments
 (0)