public final class Mapcode extends Object
Alphabet.
Mapcode objects provide methods to obtain the mapcode code in a specific alphabet. By default,
the Alphabet.ROMAN is used.| Modifier and Type | Field and Description |
|---|---|
static String |
REGEX_MAPCODE
This patterns/regular expressions is used for checking mapcode format strings.
|
| Constructor and Description |
|---|
Mapcode(String code,
Territory territory)
Create a mapcode object.
|
| Modifier and Type | Method and Description |
|---|---|
static boolean |
containsTerritory(String mapcode)
Returns whether the mapcode contains territory information or not.
|
boolean |
equals(Object obj) |
String |
getCode() |
String |
getCode(Alphabet alphabet)
Get the Mapcode string (without territory information) with standard precision.
|
String |
getCode(int precision) |
String |
getCode(int precision,
Alphabet alphabet)
Get the mapcode code (without territory information) with a specified precision.
|
String |
getCodeWithTerritory() |
String |
getCodeWithTerritory(Alphabet alphabet) |
String |
getCodeWithTerritory(int precision) |
String |
getCodeWithTerritory(int precision,
Alphabet alphabet)
Return the international mapcode as a shorter version using the ISO territory codes where possible.
|
String |
getCodeWithTerritoryFullname() |
String |
getCodeWithTerritoryFullname(Alphabet alphabet) |
String |
getCodeWithTerritoryFullname(int precision) |
String |
getCodeWithTerritoryFullname(int precision,
Alphabet alphabet)
Return the full international mapcode, including the full name of the territory and the mapcode code itself.
|
static int |
getPrecisionFormat(String mapcode)
This method return the mapcode type, given a mapcode string.
|
static double |
getSafeMaxOffsetInMeters(int precision)
Get a safe maximum for the distance between a decoded mapcode and its original
location used for encoding the mapcode.
|
Territory |
getTerritory()
Get the territory information.
|
int |
hashCode() |
static boolean |
isValidMapcodeFormat(String mapcode)
This method provides a shortcut to checking if a mapcode string is formatted properly or not at all.
|
String |
toString()
This method is defined as returning the mapcode code including its territory,
with normal precision (precision 0).
|
@Nonnull public static final String REGEX_MAPCODE
public Mapcode(@Nonnull String code, @Nonnull Territory territory) throws IllegalArgumentException
MapcodeCodec.encode(double, double) rather than creating them yourself.
Note that it is possible to create invalid mapcodes this way, which are syntactically
correct.
Note that the constructor will throw an IllegalArgumentException if the syntax of the mapcode
is not correct. The mapcode is not checked for validity, other than its syntax.code - Code of mapcode.territory - Territory.IllegalArgumentException - Thrown if syntax not valid or if the mapcode string contains
territory information.@Nonnull public String getCode(@Nullable Alphabet alphabet)
alphabet - Alphabet.@Nonnull public String getCode(int precision, @Nullable Alphabet alphabet)
precision - Precision. Range: 0..8.alphabet - Alphabet.IllegalArgumentException - Thrown if precision is out of range (must be in [0, 8]).@Nonnull public String getCode(int precision) throws IllegalArgumentException
IllegalArgumentException@Nonnull public String getCodeWithTerritoryFullname(int precision, @Nullable Alphabet alphabet) throws IllegalArgumentException
precision - Precision specifier. Range: [0, 8].alphabet - Alphabet.IllegalArgumentException - Thrown if precision is out of range (must be in [0, 8]).@Nonnull public String getCodeWithTerritoryFullname(int precision) throws IllegalArgumentException
IllegalArgumentException@Nonnull public String getCodeWithTerritoryFullname(@Nullable Alphabet alphabet)
@Nonnull public String getCodeWithTerritory(int precision, @Nullable Alphabet alphabet) throws IllegalArgumentException
precision - Precision specifier. Range: [0, 8].alphabet - Alphabet.IllegalArgumentException - Thrown if precision is out of range (must be in [0, 8]).@Nonnull public String getCodeWithTerritory(int precision) throws IllegalArgumentException
IllegalArgumentException@Nonnull public Territory getTerritory()
public static int getPrecisionFormat(@Nonnull String mapcode) throws UnknownPrecisionFormatException
mapcode - Mapcode (optionally with a territory).UnknownPrecisionFormatException - If precision format is incorrect.public static boolean isValidMapcodeFormat(@Nonnull String mapcode) throws IllegalArgumentException
mapcode - Mapcode (optionally with a territory).IllegalArgumentException - If mapcode is null.public static boolean containsTerritory(@Nonnull String mapcode) throws IllegalArgumentException
mapcode - Mapcode string, optionally with territory information.IllegalArgumentException - If mapcode has incorrect syntax.public static double getSafeMaxOffsetInMeters(int precision)
precision - Precision of mapcode.@Nonnull public String toString()
Copyright © 2017 Stichting Mapcode Foundation. All rights reserved.