-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathmapcode_legacy.h
More file actions
180 lines (156 loc) · 7.48 KB
/
mapcode_legacy.h
File metadata and controls
180 lines (156 loc) · 7.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
/*
* Copyright (C) 2014-2016 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.
*/
#ifndef __MAPCODE_LEGACY_H__
#define __MAPCODE_LEGACY_H__
#ifdef __cplusplus
extern "C" {
#endif
#include "mapcoder.h"
#include "mapcode_territories.h"
#include "mapcode_alphabets.h"
/**
* List of #defines to support legacy systems.
*/
#define decodeMapcodeToLatLon(latDeg, lonDeg, mapcode, territory) decodeUtf8MapcodeToLatLon(latDeg, lonDeg, NULL, mapcode, territory)
#define compareWithMapcodeFormat(utf8, canContainTerritory) compareUtf8WithMapcodeFormat(utf8)
#define convertTerritoryIsoNameToCode getTerritoryCode
#define coord2mc(results, lat, lon, territory) encodeLatLonToMapcodes_Deprecated(results, lat, lon,territory, 0)
#define coord2mc1(results, lat, lon, territory) encodeLatLonToSingleMapcode(results, lat, lon, territory, 0)
#define mc2coord decodeMapcodeToLatLon
#define lookslikemapcode compareWithMapcodeFormat
#define text2tc getTerritoryCode
#define tc2text convertTerritoryCodeToIsoName
#define tccontext getCountryOrParentCountry
#define tcparent getParentCountryOf
#define decode_to_roman decodeToRoman
#define encode_to_alphabet encodeToAlphabet
#define MAX_MAPCODE_TERRITORY_CODE (_TERRITORY_MAX - _TERRITORY_MIN - 1)
#define MAX_CCODE (_TERRITORY_MAX - _TERRITORY_MIN - 1)
#define NR_BOUNDARY_RECS MAPCODE_BOUNDARY_MAX
#define NR_RECS MAPCODE_BOUNDARY_MAX
#define COMPARE_MAPCODE_MISSING_CHARACTERS ERR_MAPCODE_INCOMPLETE
#define MAX_LANGUAGES _ALPHABET_MAX
#define MAPCODE_LANGUAGE_ROMAN ALPHABET_ROMAN
#define MAPCODE_LANGUAGE_GREEK ALPHABET_GREEK
#define MAPCODE_LANGUAGE_CYRILLIC ALPHABET_CYRILLIC
#define MAPCODE_LANGUAGE_HEBREW ALPHABET_HEBREW
#define MAPCODE_LANGUAGE_HINDI ALPHABET_DEVANAGARI
#define ALPHABET_HINDI ALPHABET_DEVANAGARI
#define MAPCODE_LANGUAGE_MALAYALAM ALPHABET_MALAYALAM
#define MAPCODE_LANGUAGE_GEORGIAN ALPHABET_GEORGIAN
#define MAPCODE_LANGUAGE_KATAKANA ALPHABET_KATAKANA
#define MAPCODE_LANGUAGE_THAI ALPHABET_THAI
#define MAPCODE_LANGUAGE_LAO ALPHABET_LAO
#define MAPCODE_LANGUAGE_ARMENIAN ALPHABET_ARMENIAN
#define MAPCODE_LANGUAGE_BENGALI ALPHABET_BENGALI
#define MAPCODE_LANGUAGE_GURMUKHI ALPHABET_GURMUKHI
#define MAPCODE_LANGUAGE_TIBETAN ALPHABET_TIBETAN
#define MAPCODE_LANGUAGE_ARABIC ALPHABET_ARABIC
// Some alphabets are missing because they were never supported in the legacy library.
/**
* DEPRECATED OLD VARIANT, NOT THREAD-SAFE:
*
* Encode a latitude, longitude pair (in degrees) to a set of Mapcodes. Not thread-safe!
*
* Arguments:
* mapcodesAndTerritories - Results set of mapcodes and territories.
* The caller must pass an array of at least 2 * MAX_NR_OF_MAPCODE_RESULTS
* string points, which must NOT be allocated or de-allocated by the caller.
* The resulting strings are statically allocated by the library and will be overwritten
* by the next call to this method!
* lat - Latitude, in degrees. Range: -90..90.
* lon - Longitude, in degrees. Range: -180..180.
* territory - Territory (e.g. as obtained from getTerritoryCode), used as encoding context.
* Pass TERRITORY_NONE or TERRITORY_UNKNOWN to get Mapcodes for all territories.
* extraDigits - Number of extra "digits" to add to the generated mapcode. The preferred default is 0.
* Other valid values are 1 and 2, which will add extra letters to the mapcodes to
* make them represent the coordinate more accurately.
*
* Returns:
* Number of results stored in parameter results. Always >= 0 (0 if no encoding was possible or an error occurred).
* The results are stored as pairs (Mapcode, territory name) in:
* (results[0], results[1])...(results[(2 * N) - 2], results[(2 * N) - 1])
*/
int encodeLatLonToMapcodes_Deprecated( // Warning: this method is deprecated and not thread-safe.
char **mapcodesAndTerritories,
double latDeg,
double lonDeg,
enum Territory territory,
int extraDigits);
/**
* DEPRECATED OLD VARIANT, NOT THREAD-SAFE:
*
* Convert a territory to a territory name.
* Non-threadsafe routine which uses static storage, overwritten at each call.
*
* Arguments:
* territory - Territory to get the name of.
* userShortName - Pass 0 for full name, 1 for short name (state codes may be ambiguous).
*
* Returns:
* Pointer to result. String will be empty if territory illegal.
*/
const char *convertTerritoryCodeToIsoName_Deprecated(
enum Territory territory,
int useShortName);
/**
* Decode a string to Roman characters.
*
* Arguments:
* asciiString - Buffer to be filled with the ASCII string result.
* maxLength - Size of asciiString buffer.
* utf16String - Unicode string to decode, allocated by caller.
*
* Returns:
* Pointer to same buffer as asciiString (allocated by caller), which holds the result.
*/
char *convertToRoman(char *asciiString, int maxLength, const UWORD *utf16String);
/**
* Encode a string to Alphabet characters for a language.
*
* Arguments:
* utf16String - Buffer to be filled with the Unicode string result.
* asciiString - ASCII string to encode.
* maxLength - Size of utf16String buffer.
* alphabet - Alphabet to use.
*
* Returns:
* Encoded Unicode string, points at buffer from 'utf16String', allocated/deallocated by caller.
*/
UWORD *convertToAlphabet(UWORD *utf16String, int maxLength, const char *asciiString, enum Alphabet alphabet);
/**
* DEPRECATED OLD VARIANT, NOT THREAD-SAFE:
*
* Uses a pre-allocated static buffer, overwritten by the next call
* Returns converted string. allocated by the library.
*
* String must NOT be de-allocated by the caller.
* It will be overwritten by a subsequent call to this method!
*/
const char *decodeToRoman_Deprecated(const UWORD *utf16String);
/**
* DEPRECATED OLD VARIANT, NOT THREAD-SAFE:
*
* Returns converted string. allocated by the library.
*
* String must NOT be de-allocated by the caller.
* It will be overwritten by a subsequent call to this method!
*/
const UWORD *encodeToAlphabet_Deprecated(const char *asciiString, enum Alphabet alphabet);
#ifdef __cplusplus
}
#endif
#endif // __MAPCODE_LEGACY_H__