public final class MapcodeCodec extends Object
| Modifier and Type | Method and Description |
|---|---|
static Point |
decode(String mapcode)
Decode a mapcode to a Point.
|
static Point |
decode(String mapcode,
Territory defaultTerritoryContext)
Decode a mapcode to a Point.
|
static List<Mapcode> |
encode(double latDeg,
double lonDeg)
Encode a lat/lon pair to a mapcode with territory information.
|
static List<Mapcode> |
encode(double latDeg,
double lonDeg,
Territory restrictToTerritory)
Encode a lat/lon pair to a mapcode with territory information, for a specific territory.
|
static List<Mapcode> |
encode(Point point) |
static List<Mapcode> |
encode(Point point,
Territory restrictToTerritory) |
static Mapcode |
encodeToInternational(double latDeg,
double lonDeg)
Encode a lat/lon pair to its unambiguous, international mapcode.
|
static Mapcode |
encodeToInternational(Point point) |
static Mapcode |
encodeToShortest(double latDeg,
double lonDeg,
Territory restrictToTerritory)
Encode a lat/lon pair to its shortest mapcode with territory information.
|
static Mapcode |
encodeToShortest(Point point,
Territory restrictToTerritory) |
static boolean |
isNearMultipleBorders(Point point,
Territory territory)
Is coordinate near multiple territory borders?
|
@Nonnull public static List<Mapcode> encode(double latDeg, double lonDeg) throws IllegalArgumentException
encodeToShortest(double, double, Territory).
The international code can be obtained from the list by using: "results.get(results.size() - 1)", or
you can use encodeToInternational(double, double), which is faster.latDeg - Latitude, accepted range: -90..90.lonDeg - Longitude, accepted range: -180..180.Mapcode.IllegalArgumentException - Thrown if latitude or longitude are out of range.@Nonnull public static List<Mapcode> encode(@Nonnull Point point) throws IllegalArgumentException
IllegalArgumentException@Nonnull public static List<Mapcode> encode(double latDeg, double lonDeg, @Nullable Territory restrictToTerritory) throws IllegalArgumentException
encodeToShortest(double, double, Territory).latDeg - Latitude, accepted range: -90..90 (limited to this range if outside).lonDeg - Longitude, accepted range: -180..180 (wrapped to this range if outside).restrictToTerritory - Try to encode only within this territory, see Territory. May be null.Mapcode. This list is empty if no
Mapcode can be generated for this territory matching the lat/lon.IllegalArgumentException - Thrown if latitude or longitude are out of range.@Nonnull public static List<Mapcode> encode(@Nonnull Point point, @Nullable Territory restrictToTerritory) throws IllegalArgumentException
IllegalArgumentException@Nonnull public static Mapcode encodeToShortest(double latDeg, double lonDeg, @Nonnull Territory restrictToTerritory) throws IllegalArgumentException, UnknownMapcodeException
latDeg - Latitude, accepted range: -90..90.lonDeg - Longitude, accepted range: -180..180.restrictToTerritory - Try to encode only within this territory, see Territory. Cannot be null.Mapcode.IllegalArgumentException - Thrown if latitude or longitude are out of range.UnknownMapcodeException - Thrown if no mapcode was found for the lat/lon matching the territory.@Nonnull public static Mapcode encodeToShortest(@Nonnull Point point, @Nonnull Territory restrictToTerritory) throws IllegalArgumentException, UnknownMapcodeException
@Nonnull public static Mapcode encodeToInternational(double latDeg, double lonDeg) throws IllegalArgumentException
latDeg - Latitude, accepted range: -90..90.lonDeg - Longitude, accepted range: -180..180.Mapcode.IllegalArgumentException - Thrown if latitude or longitude are out of range.@Nonnull public static Mapcode encodeToInternational(@Nonnull Point point) throws IllegalArgumentException
IllegalArgumentException@Nonnull public static Point decode(@Nonnull String mapcode) throws UnknownMapcodeException, IllegalArgumentException, UnknownPrecisionFormatException
mapcode - Mapcode.UnknownMapcodeException - Thrown if the mapcode has the correct syntax,
but cannot be decoded into a point.UnknownPrecisionFormatException - Thrown if the precision format is incorrect.IllegalArgumentException - Thrown if arguments are null, or if the syntax of the mapcode is incorrect.@Nonnull public static Point decode(@Nonnull String mapcode, @Nullable Territory defaultTerritoryContext) throws UnknownMapcodeException, IllegalArgumentException, UnknownPrecisionFormatException
mapcode - Mapcode.defaultTerritoryContext - Default territory context for disambiguation purposes. May be null.UnknownMapcodeException - Thrown if the mapcode has the right syntax, but cannot be decoded into a point.UnknownPrecisionFormatException - Thrown if the precision format is incorrect.IllegalArgumentException - Thrown if arguments are null, or if the syntax of the mapcode is incorrect.public static boolean isNearMultipleBorders(@Nonnull Point point, @Nonnull Territory territory)
point - Latitude/Longitude in degrees.territory - Territory.Copyright © 2017 Stichting Mapcode Foundation. All rights reserved.