Skip to content

Commit f419e67

Browse files
committed
Merge pull request #19 from mapcode-foundation/dev
Ready for release 2.0.2
2 parents ac0167c + 6cc713e commit f419e67

File tree

10 files changed

+360
-405
lines changed

10 files changed

+360
-405
lines changed

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<artifactId>mapcode</artifactId>
99

1010
<packaging>jar</packaging>
11-
<version>2.0.1</version>
11+
<version>2.0.2-SNAPSHOT</version>
1212

1313
<name>Mapcode Java Library</name>
1414
<description>

src/main/java/com/mapcode/Alphabet.java

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,15 @@
2121
import static com.mapcode.CheckArgs.checkNonnull;
2222

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

4346
/**
44-
* The numeric code is synonym for the alphanumeric code. It can be used in the decoder
45-
* to define a territory as well.
47+
* The numeric code is synonym for the alphanumeric code. Used in the decoder.
4648
*/
4749
private final int number;
4850

@@ -65,7 +67,7 @@ int getNumber() {
6567
}
6668

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

8587
/**
86-
* Static checking of the static data structures.
88+
* Static consistency check of internal data structures.
8789
*/
8890
static {
8991
int i = 0;

src/main/java/com/mapcode/CheckArgs.java

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,22 +22,16 @@
2222
import static com.mapcode.Mapcode.getPrecisionFormat;
2323

2424
/**
25-
* Package private helper methods to check arguments for validity.
25+
* ----------------------------------------------------------------------------------------------
26+
* Package private implementation class. For internal use within the Mapcode implementation only.
27+
* ----------------------------------------------------------------------------------------------
2628
*/
2729
class CheckArgs {
2830

2931
private CheckArgs() {
3032
// Prevent instantiation.
3133
}
3234

33-
static void checkRange(@Nonnull final String param, final double value,
34-
final double min, final double max) throws IllegalArgumentException {
35-
if ((value < min) || (value > max)) {
36-
throw new IllegalArgumentException("Parameter " + param +
37-
" should be in range [" + min + ", " + max + "], but is: " + value);
38-
}
39-
}
40-
4135
static void checkNonnull(@Nonnull final String param, @Nullable final Object obj)
4236
throws IllegalArgumentException {
4337
if (obj == null) {

src/main/java/com/mapcode/Mapcode.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,7 @@ public static PrecisionFormat getPrecisionFormat(@Nonnull final String mapcode)
333333
* actually a valid mapcode representing a location on Earth.
334334
* @throws IllegalArgumentException If mapcode is null.
335335
*/
336-
public static boolean isValidPrecisionFormat(@Nonnull final String mapcode) throws IllegalArgumentException {
336+
public static boolean isValidMapcodeFormat(@Nonnull final String mapcode) throws IllegalArgumentException {
337337
checkNonnull("mapcode", mapcode);
338338
try {
339339
// Throws an exception if the format is incorrect.

src/main/java/com/mapcode/ParentTerritory.java

Lines changed: 0 additions & 49 deletions
This file was deleted.

src/main/java/com/mapcode/Point.java

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,6 @@
2323
import static com.mapcode.CheckArgs.checkNonnull;
2424

2525
/**
26-
* ----------------------------------------------------------------------------------------------
27-
* Package private implementation class. For internal use within the mapcode implementation only.
28-
* ----------------------------------------------------------------------------------------------
29-
*
3026
* This class defines a class for lat/lon points.
3127
*/
3228
public class Point {
@@ -37,13 +33,6 @@ public class Point {
3733
public static final double LAT_DEG_MIN = -90.0;
3834
public static final double LAT_DEG_MAX = 90.0;
3935

40-
public static final int LON_MICRODEG_MIN = degToMicroDeg(LON_DEG_MIN);
41-
public static final int LON_MICRODEG_MAX = degToMicroDeg(LON_DEG_MAX);
42-
public static final int LAT_MICRODEG_MIN = degToMicroDeg(LAT_DEG_MIN);
43-
public static final int LAT_MICRODEG_MAX = degToMicroDeg(LAT_DEG_MAX);
44-
45-
public static final double MICRODEG_TO_DEG_FACTOR = 1000000.0;
46-
4736
// Radius of Earth.
4837
public static final double EARTH_RADIUS_X_METERS = 6378137.0;
4938
public static final double EARTH_RADIUS_Y_METERS = 6356752.3;
@@ -155,8 +144,7 @@ public static double distanceInMeters(@Nonnull final Point p1, @Nonnull final Po
155144
final double deltaYMeters = degreesLatToMeters(deltaLatDeg);
156145

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

162150
public static double degreesLatToMeters(final double latDegrees) {
@@ -236,6 +224,11 @@ private Point(final double latDeg, final double lonDeg, final boolean wrap) {
236224
/**
237225
* Package private methods. Only used in the mapcode implementation modules.
238226
*/
227+
static final double MICRODEG_TO_DEG_FACTOR = 1000000.0;
228+
static final int LON_MICRODEG_MIN = degToMicroDeg(LON_DEG_MIN);
229+
static final int LON_MICRODEG_MAX = degToMicroDeg(LON_DEG_MAX);
230+
static final int LAT_MICRODEG_MIN = degToMicroDeg(LAT_DEG_MIN);
231+
static final int LAT_MICRODEG_MAX = degToMicroDeg(LAT_DEG_MAX);
239232

240233
@Nonnull
241234
static Point fromMicroDeg(final int latMicroDeg, final int lonMicroDeg) {
@@ -287,8 +280,7 @@ Point wrap() {
287280
* @return Limited to [-90, 90].
288281
*/
289282
static double mapToLat(final double value) {
290-
final double lat = (value < -90.0) ? -90.0 : ((value > 90.0) ? 90.0 : value);
291-
return lat;
283+
return (value < -90.0) ? -90.0 : ((value > 90.0) ? 90.0 : value);
292284
}
293285

294286
/**

0 commit comments

Comments
 (0)