@@ -72,12 +72,12 @@ extern "C" {
7272
7373#define MAX_MAPCODE_RESULT_ASCII_LEN (MAX_ISOCODE_ASCII_LEN + 1 + MAX_CLEAN_MAPCODE_ASCII_LEN + 1) // Max. chars to store a single result (including zero-terminator).
7474
75- #define MAX_TERRITORY_FULLNAME_UTF8_LEN 111 // Max. number of characters to store the longest possible territory name (in UTF8 )
75+ #define MAX_TERRITORY_FULLNAME_UTF8_LEN 111 // Max. number of characters to store the longest possible territory name (in UTF-8 )
7676
7777
78- #define MAX_MAPCODE_RESULT_UTF8_LEN (MAX_MAPCODE_RESULT_ASCII_LEN * 3) // One mapcode character can become at most 3 UTF8characters .
78+ #define MAX_MAPCODE_RESULT_UTF8_LEN (MAX_MAPCODE_RESULT_ASCII_LEN * 3) // One mapcode character can become at most 3 UTF-8 characters .
7979
80- #define MAX_MAPCODE_RESULT_UTF16_LEN (MAX_MAPCODE_RESULT_ASCII_LEN) // Each mapcode character can become one UTF16 word.
80+ #define MAX_MAPCODE_RESULT_UTF16_LEN (MAX_MAPCODE_RESULT_ASCII_LEN) // Each mapcode character can become one UTF-16 word.
8181
8282
8383// The constants are also exported as variables, to allow other languages to use them.
@@ -94,8 +94,8 @@ extern int _MAX_MAPCODE_RESULT_UTF16_LEN;
9494extern int _MAX_ALPHABETS_PER_TERRITORY ;
9595
9696/**
97- * The type Mapcodes hold a number of mapcodes , for example from an encoding call.
98- * If a result contains a space, that space seperates the territory ISO3166 code from the mapcode.
97+ * The type ` Mapcodes` holds a number of Mapcodes , for example from an encoding call.
98+ * If a result contains a space, that space separates the territory ISO3166 code from the mapcode.
9999 * International mapcodes never include a territory ISO3166 code, nor a space.
100100 */
101101typedef struct {
@@ -105,13 +105,13 @@ typedef struct {
105105
106106
107107/**
108- * The MapcodeElement structure is returned by decodeXXX and can be used to inspect or clean up the
109- * mapcode input. The field territoryISO contains the cleaned up territory code from the input, but
108+ * The `MapcodeElements` structure is returned by decodeXXX and can be used to inspect or clean up the
109+ * mapcode input. The field ` territoryISO` contains the cleaned- up territory code from the input, but
110110 * the code may be abbreviated, or even missing (if it wasn't available in the input).
111111 *
112112 * If you want to get a full territory code, use:
113- * char isoName[MAX_ISOCODE_ASCII_LEN + 1];
114- * getTerritoryIsoName(isoName, mapcodeElement .territoryCode, 0)
113+ * char isoName[MAX_ISOCODE_ASCII_LEN + 1];
114+ * getTerritoryIsoName(isoName, mapcodeElements .territoryCode, 0);
115115 */
116116typedef struct {
117117 char territoryISO [MAX_ISOCODE_ASCII_LEN + 1 ]; // The (trimmed and uppercased) territory code, from the input.
@@ -136,7 +136,7 @@ enum MapcodeError {
136136 ERR_INVALID_MAPCODE_FORMAT , // string not recognized as mapcode format
137137 ERR_INVALID_CHARACTER , // mapcode contains an invalid character
138138 ERR_BAD_ARGUMENTS , // an argument is invalid (e.g. NULL)
139- ERR_INVALID_ENDVOWELS , // mapcodes ends in UE or UU
139+ ERR_INVALID_ENDVOWELS , // mapcode ends in UE or UU
140140 ERR_EXTENSION_INVALID_LENGTH , // precision extension too long, or empty
141141 ERR_EXTENSION_INVALID_CHARACTER , // bad precision extension character (e.g. Z)
142142 ERR_UNEXPECTED_DOT , // mapcode dot can not be in this position
@@ -156,7 +156,7 @@ enum MapcodeError {
156156 ERR_MISSING_TERRITORY , // mapcode can not be decoded without territory
157157 ERR_EXTENSION_UNDECODABLE , // extension does not decode to valid coordinate
158158 ERR_MAPCODE_UNDECODABLE , // mapcode does not decode inside territory
159- ERR_BAD_COORDINATE , // latitude or longitude is NAN or infinite
159+ ERR_BAD_COORDINATE , // latitude or longitude is NaN or infinite
160160
161161 // all OK.
162162
@@ -178,9 +178,8 @@ enum MapcodeError {
178178 * make them represent the coordinate more accurately.
179179 *
180180 * Returns:
181- * Number of results stored in parameter results. Always >= 0 (0 if no encoding was possible or an error occurred).
182- * The results are stored as pairs (Mapcode, territory name) in:
183- * (results[0], results[1])...(results[(2 * N) - 2], results[(2 * N) - 1])
181+ * Number of results stored in `mapcodes->count`. Always >= 0 (0 if no encoding was possible or an error occurred).
182+ * Each resulting string is stored in `mapcodes->mapcode[i]` and may include a territory ISO3166 code followed by a space when applicable.
184183 */
185184
186185int encodeLatLonToMapcodes (
@@ -193,12 +192,11 @@ int encodeLatLonToMapcodes(
193192
194193/**
195194 * Encode a latitude, longitude pair (in degrees) to a single Mapcode: the shortest possible for the given territory
196- * (which can be 0 for all territories).
195+ * (pass TERRITORY_NONE or TERRITORY_UNKNOWN to consider all territories).
197196 *
198197 * Arguments:
199- * result - Returned Mapcode. The caller must not allocate or de-allocated this string.
200- * The resulting string MUST be allocated (and de-allocated) by the caller.
201- * The caller should allocate at least MAX_MAPCODE_RESULT_ASCII_LEN characters for the string.
198+ * mapcode - Output buffer for the resulting Mapcode. The caller must allocate this buffer
199+ * with capacity of at least MAX_MAPCODE_RESULT_ASCII_LEN characters.
202200 * lat - Latitude, in degrees. Range: -90..90.
203201 * lon - Longitude, in degrees. Range: -180..180.
204202 * territory - Territory (e.g. as obtained from getTerritoryCode), used as encoding context.
@@ -224,9 +222,8 @@ int encodeLatLonToSingleMapcode(
224222 * (like Swift).
225223 *
226224 * Arguments:
227- * result - Returned Mapcode. The caller must not allocate or de-allocated this string.
228- * The resulting string MUST be allocated (and de-allocated) by the caller.
229- * The caller should allocate at least MAX_MAPCODE_RESULT_ASCII_LEN characters for the string.
225+ * mapcode - Output buffer for the resulting Mapcode. The caller must allocate this buffer
226+ * with capacity of at least MAX_MAPCODE_RESULT_ASCII_LEN characters.
230227 * lat - Latitude, in degrees. Range: -90..90.
231228 * lon - Longitude, in degrees. Range: -180..180.
232229 * territory - Territory (e.g. as obtained from getTerritoryCode), used as encoding context.
@@ -251,7 +248,7 @@ int encodeLatLonToSelectedMapcode(
251248
252249
253250/**
254- * Decode a utf8 or ascii Mapcode to a latitude, longitude pair (in degrees).
251+ * Decode a UTF-8 or ASCII Mapcode to a latitude/ longitude pair (in degrees).
255252 *
256253 * Arguments:
257254 * lat - Decoded latitude, in degrees. Range: -90..90.
@@ -262,7 +259,7 @@ int encodeLatLonToSelectedMapcode(
262259 * mapcodeElements - If not NULL, filled with analysis of the string (unless an error was encountered).
263260 *
264261 * Returns:
265- * ERR_OK if encoding succeeded.
262+ * ERR_OK if decoding succeeded.
266263 */
267264enum MapcodeError decodeMapcodeToLatLonUtf8 (
268265 double * latDeg ,
@@ -273,18 +270,18 @@ enum MapcodeError decodeMapcodeToLatLonUtf8(
273270
274271
275272/**
276- * Decode a utf16 Mapcode to a latitude, longitude pair (in degrees).
273+ * Decode a UTF-16 Mapcode to a latitude/ longitude pair (in degrees).
277274 *
278275 * Arguments:
279276 * lat - Decoded latitude, in degrees. Range: -90..90.
280277 * lon - Decoded longitude, in degrees. Range: -180..180.
281- * mapcodeElements - If not NULL, filled with analysis of the string (unless an error was encountered)
282- * utf8string - Mapcode to decode (ascii or utf8 string).
278+ * utf16string - Mapcode to decode (UTF-16 string).
283279 * territory - Territory (e.g. as obtained from getTerritoryCode), used as decoding context.
284280 * Pass TERRITORY_NONE if not available.
281+ * mapcodeElements - If not NULL, filled with analysis of the string (unless an error was encountered).
285282 *
286283 * Returns:
287- * ERR_OK if encoding succeeded.
284+ * ERR_OK if decoding succeeded.
288285 */
289286enum MapcodeError decodeMapcodeToLatLonUtf16 (
290287 double * latDeg ,
@@ -299,7 +296,7 @@ enum MapcodeError decodeMapcodeToLatLonUtf16(
299296 * the return value ERR_OK indicates the string has the Mapcode format, much like string comparison strcmp returns.)
300297 *
301298 * Arguments:
302- * utf8String/utf16String - Mapcode string to check, in UTF8 or UTF16 format.
299+ * utf8String/utf16String - Mapcode string to check, in UTF-8 or UTF-16 format.
303300 *
304301 * Returns:
305302 * ERR_OK if the string has a correct Mapcode format, another ERR_XXX value if the string does
@@ -318,8 +315,8 @@ enum MapcodeError compareWithMapcodeFormatUtf16(const UWORD* utf16String);
318315 * Convert an ISO3166 territory code to a territory.
319316 *
320317 * Arguments:
321- * territoryISO - String starting with ISO3166 code of territory (e.g. "USA" or "US-CA").
322- * parentTerritoryCode - Parent territory, or TERRITORY_NONE if not available.
318+ * territoryISO - String starting with ISO3166 code of territory (e.g. "USA" or "US-CA").
319+ * optionalTerritoryContext - Parent territory, or TERRITORY_NONE if not available.
323320 *
324321 * Returns:
325322 * Territory (> _TERRITORY_MIN) if succeeded, or TERRITORY_NONE if failed.
@@ -333,9 +330,9 @@ enum Territory getTerritoryCode(
333330 * Convert a territory to a territory name.
334331 *
335332 * Arguments:
336- * territoryISO - String to territory ISO code name result .
333+ * territoryISO - Output buffer for the territory ISO code name.
337334 * territory - Territory to get the name of.
338- * userShortName - Pass 0 for full name, 1 for short name (state codes may be ambiguous).
335+ * useShortName - Pass 0 for full name, 1 for short name (state codes may be ambiguous).
339336 *
340337 * Returns:
341338 * Pointer to result. String will be empty if territory illegal.
@@ -347,8 +344,8 @@ char* getTerritoryIsoName(
347344
348345
349346/**
350- * Given a territory, return the territory itself it it was a country, or return its parent
351- * territory if it was a subdivision (e.g. a state).
347+ * Given a territory, return the territory itself if it is a country, or return its parent
348+ * territory if it is a subdivision (e.g. a state).
352349 *
353350 * Arguments:
354351 * territory - territory (either a country or a subdivision, e.g. a state).
@@ -418,7 +415,7 @@ int multipleBordersNearby(
418415 * Returns territory names in English. There's always at least 1 alternative (with index 0).
419416 *
420417 * Arguments:
421- * territoryName - Target string, allocated by caller to be at least MAX_TERRITORY_FULLNAME_ASCII_LEN + 1 bytes.
418+ * territoryName - Target string, allocated by caller to be at least MAX_TERRITORY_FULLNAME_UTF8_LEN + 1 bytes.
422419 * territory - Territory to get name for.
423420 * alternative - Which name to get, must be >= 0 (0 = default, 1 = first alternative, 2 = second etc.).
424421 *
@@ -490,7 +487,7 @@ int getFullTerritoryNameInLocaleInAlphabetUtf8(
490487
491488
492489/**
493- * This struct contains the returned alphabest for getAlphabetsForTerritory. The 'count' specifies
490+ * This struct contains the returned alphabets for getAlphabetsForTerritory. The 'count' specifies
494491 * how many alphabets are listed in 'alphabet', range [1, MAX_ALPHABETS_PER_TERRITORY].
495492 */
496493#define MAX_ALPHABETS_PER_TERRITORY 3
@@ -510,7 +507,7 @@ typedef struct {
510507 *
511508 * Returns:
512509 * A pointer to a TerritoryAlphabets structure, or NULL if the territory is invalid.
513- * (The pointer is owned by the library and should not be dealloacted by the caller.)
510+ * (The pointer is owned by the library and should not be deallocated by the caller.)
514511 */
515512const TerritoryAlphabets * getAlphabetsForTerritory (enum Territory territory );
516513
@@ -525,7 +522,7 @@ const TerritoryAlphabets* getAlphabetsForTerritory(enum Territory territory);
525522 * alphabet - Alphabet to use.
526523 *
527524 * Returns:
528- * Encode UTF8 string (pointer to utf8String buffer), allocated and deallocated by the caller.
525+ * Encoded UTF-8 string (pointer to utf8String buffer), allocated and deallocated by the caller.
529526 */
530527char * convertMapcodeToAlphabetUtf8 (char * utf8String , const char * asciiString , enum Alphabet alphabet );
531528
@@ -540,7 +537,7 @@ char* convertMapcodeToAlphabetUtf8(char* utf8String, const char* asciiString, en
540537 * alphabet - Alphabet to use.
541538 *
542539 * Returns:
543- * Encode UTF16 string (pointer to utf16String buffer), allocated and deallocated by the caller.
540+ * Encoded UTF-16 string (pointer to utf16String buffer), allocated and deallocated by the caller.
544541 */
545542UWORD * convertMapcodeToAlphabetUtf16 (UWORD * utf16String , const char * asciiString , enum Alphabet alphabet );
546543
0 commit comments