Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<artifactId>mapcode</artifactId>

<packaging>jar</packaging>
<version>2.0.1</version>
<version>2.0.2-SNAPSHOT</version>

<name>Mapcode Java Library</name>
<description>
Expand Down
18 changes: 10 additions & 8 deletions src/main/java/com/mapcode/Alphabet.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,15 @@
import static com.mapcode.CheckArgs.checkNonnull;

/**
* This enum defines all alphabets supported for mapcodes. Mapcodes can be safely converted between
* alphabets and fed to the mapcode decoder in the regular ASCII Roman alphabet or any other.
* This enum defines all alphabets supported for mapcodes. Note that an alphabet is different from a
* language or locale. An alternative name for an alphabet is "script".
*
* Mapcodes can be safely converted between alphabets and fed to the mapcode decoder in the regular
* ASCII Roman alphabet or any other.
*/
public enum Alphabet {
ROMAN(0),
GREEK(1),
ROMAN(0), // The numeric codes for alphabets are used by the implementation
GREEK(1), // of the mapcode library. Do not change them.
CYRILLIC(2),
HEBREW(3),
HINDI(4),
Expand All @@ -41,8 +44,7 @@ public enum Alphabet {
TIBETAN(13);

/**
* The numeric code is synonym for the alphanumeric code. It can be used in the decoder
* to define a territory as well.
* The numeric code is synonym for the alphanumeric code. Used in the decoder.
*/
private final int number;

Expand All @@ -65,7 +67,7 @@ int getNumber() {
}

/**
* Return alphabet from a string, which can be a numeric or alpha code.
* Return alphabet from a string, which needs to be an alphanumeric code.
*
* @param alphaCode Alphabet, alphanumeric code.
* @return Alphabet.
Expand All @@ -83,7 +85,7 @@ public static Alphabet fromString(@Nonnull final String alphaCode) throws Unknow
}

/**
* Static checking of the static data structures.
* Static consistency check of internal data structures.
*/
static {
int i = 0;
Expand Down
12 changes: 3 additions & 9 deletions src/main/java/com/mapcode/CheckArgs.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,22 +22,16 @@
import static com.mapcode.Mapcode.getPrecisionFormat;

/**
* Package private helper methods to check arguments for validity.
* ----------------------------------------------------------------------------------------------
* Package private implementation class. For internal use within the Mapcode implementation only.
* ----------------------------------------------------------------------------------------------
*/
class CheckArgs {

private CheckArgs() {
// Prevent instantiation.
}

static void checkRange(@Nonnull final String param, final double value,
final double min, final double max) throws IllegalArgumentException {
if ((value < min) || (value > max)) {
throw new IllegalArgumentException("Parameter " + param +
" should be in range [" + min + ", " + max + "], but is: " + value);
}
}

static void checkNonnull(@Nonnull final String param, @Nullable final Object obj)
throws IllegalArgumentException {
if (obj == null) {
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/mapcode/Mapcode.java
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ public static PrecisionFormat getPrecisionFormat(@Nonnull final String mapcode)
* actually a valid mapcode representing a location on Earth.
* @throws IllegalArgumentException If mapcode is null.
*/
public static boolean isValidPrecisionFormat(@Nonnull final String mapcode) throws IllegalArgumentException {
public static boolean isValidMapcodeFormat(@Nonnull final String mapcode) throws IllegalArgumentException {
checkNonnull("mapcode", mapcode);
try {
// Throws an exception if the format is incorrect.
Expand Down
49 changes: 0 additions & 49 deletions src/main/java/com/mapcode/ParentTerritory.java

This file was deleted.

22 changes: 7 additions & 15 deletions src/main/java/com/mapcode/Point.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,6 @@
import static com.mapcode.CheckArgs.checkNonnull;

/**
* ----------------------------------------------------------------------------------------------
* Package private implementation class. For internal use within the mapcode implementation only.
* ----------------------------------------------------------------------------------------------
*
* This class defines a class for lat/lon points.
*/
public class Point {
Expand All @@ -37,13 +33,6 @@ public class Point {
public static final double LAT_DEG_MIN = -90.0;
public static final double LAT_DEG_MAX = 90.0;

public static final int LON_MICRODEG_MIN = degToMicroDeg(LON_DEG_MIN);
public static final int LON_MICRODEG_MAX = degToMicroDeg(LON_DEG_MAX);
public static final int LAT_MICRODEG_MIN = degToMicroDeg(LAT_DEG_MIN);
public static final int LAT_MICRODEG_MAX = degToMicroDeg(LAT_DEG_MAX);

public static final double MICRODEG_TO_DEG_FACTOR = 1000000.0;

// Radius of Earth.
public static final double EARTH_RADIUS_X_METERS = 6378137.0;
public static final double EARTH_RADIUS_Y_METERS = 6356752.3;
Expand Down Expand Up @@ -155,8 +144,7 @@ public static double distanceInMeters(@Nonnull final Point p1, @Nonnull final Po
final double deltaYMeters = degreesLatToMeters(deltaLatDeg);

// Calculate length through Earth. This is an approximation, but works fine for short distances.
final double lenMeters = Math.sqrt((deltaXMeters * deltaXMeters) + (deltaYMeters * deltaYMeters));
return lenMeters;
return Math.sqrt((deltaXMeters * deltaXMeters) + (deltaYMeters * deltaYMeters));
}

public static double degreesLatToMeters(final double latDegrees) {
Expand Down Expand Up @@ -236,6 +224,11 @@ private Point(final double latDeg, final double lonDeg, final boolean wrap) {
/**
* Package private methods. Only used in the mapcode implementation modules.
*/
static final double MICRODEG_TO_DEG_FACTOR = 1000000.0;
static final int LON_MICRODEG_MIN = degToMicroDeg(LON_DEG_MIN);
static final int LON_MICRODEG_MAX = degToMicroDeg(LON_DEG_MAX);
static final int LAT_MICRODEG_MIN = degToMicroDeg(LAT_DEG_MIN);
static final int LAT_MICRODEG_MAX = degToMicroDeg(LAT_DEG_MAX);

@Nonnull
static Point fromMicroDeg(final int latMicroDeg, final int lonMicroDeg) {
Expand Down Expand Up @@ -287,8 +280,7 @@ Point wrap() {
* @return Limited to [-90, 90].
*/
static double mapToLat(final double value) {
final double lat = (value < -90.0) ? -90.0 : ((value > 90.0) ? 90.0 : value);
return lat;
return (value < -90.0) ? -90.0 : ((value > 90.0) ? 90.0 : value);
}

/**
Expand Down
Loading