Skip to content

Commit 58654e0

Browse files
committed
Release 1.40
1 parent 15e6f02 commit 58654e0

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

64 files changed

+5040057
-9797
lines changed

NOTICE

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
-------------------------------------------------------------------------------
2+
MAPCODE JAVA LIBRARY
3+
-------------------------------------------------------------------------------
4+
15
Original C library created by Pieter Geelen. Work on Java version
26
of the Mapcode library by Rijn Buve and Matthew Lowden.
37

README

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,30 @@
1+
-------------------------------------------------------------------------------
2+
MAPCODE LIBRARY FOR JAVA
3+
-------------------------------------------------------------------------------
4+
Copyright (C) 2014 Stichting Mapcode Foundation (http://www.mapcode.com)
5+
6+
Licensed under the Apache License, Version 2.0 (the "License");
7+
you may not use this file except in compliance with the License.
8+
You may obtain a copy of the License at
9+
10+
http://www.apache.org/licenses/LICENSE-2.0
11+
12+
Unless required by applicable law or agreed to in writing, software
13+
distributed under the License is distributed on an "AS IS" BASIS,
14+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
See the License for the specific language governing permissions and
16+
limitations under the License.
17+
118
Original C library created by Pieter Geelen. Work on Java version
219
of the Mapcode library by Rijn Buve and Matthew Lowden.
320

421
This Java project contains a library to encode latitude/longitude pairs to Mapcodes
522
and to decode Mapcodes back to latitude/longitude pairs.
623

724
For more information, see: http://www.mapcode.com.
25+
26+
-------------------------------------------------------------------------------
27+
RELEASE NOTES
28+
-------------------------------------------------------------------------------
29+
30+
See file: src/site/apt/ReleaseNotes.apt.vm

pom.xml

Lines changed: 53 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<artifactId>mapcode</artifactId>
99

1010
<packaging>jar</packaging>
11-
<version>1.0-SNAPSHOT</version>
11+
<version>1.40</version>
1212

1313
<name>Mapcode Java Library</name>
1414
<description>
@@ -21,10 +21,54 @@
2121
<url>http://mapcode.com</url>
2222
</organization>
2323

24+
<developers>
25+
<developer>
26+
<id>pieter</id>
27+
<name>Pieter Geelen</name>
28+
<email>[email protected]</email>
29+
<organization>Mapcode</organization>
30+
<roles>
31+
<role>Founder</role>
32+
</roles>
33+
</developer>
34+
35+
<developer>
36+
<id>rijn</id>
37+
<name>Rijn Buve</name>
38+
<email>[email protected]</email>
39+
<organization>Mapcode</organization>
40+
<roles>
41+
<role>Developer</role>
42+
</roles>
43+
</developer>
44+
45+
<developer>
46+
<id>matthew</id>
47+
<name>Matthew Lowden</name>
48+
<email>[email protected]</email>
49+
<organization>Mapcode</organization>
50+
<roles>
51+
<role>Developer</role>
52+
</roles>
53+
</developer>
54+
</developers>
55+
56+
<licenses>
57+
<license>
58+
<name>Apache License, Version 2.0</name>
59+
<url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
60+
<distribution>repo</distribution>
61+
<comments>A business-friendly OSS license</comments>
62+
</license>
63+
</licenses>
64+
2465
<url>http://mapcode.com</url>
2566

2667
<!-- Dependencies on other packages. -->
2768
<properties>
69+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
70+
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
71+
2872
<gson.version>2.3</gson.version>
2973
<jsr305.version>3.0.0</jsr305.version>
3074
<junit.version>4.11</junit.version>
@@ -34,13 +78,6 @@
3478

3579
<dependencies>
3680

37-
<!-- JSON. -->
38-
<dependency>
39-
<groupId>com.google.code.gson</groupId>
40-
<artifactId>gson</artifactId>
41-
<version>${gson.version}</version>
42-
</dependency>
43-
4481
<!-- Logging. -->
4582
<dependency>
4683
<groupId>log4j</groupId>
@@ -77,5 +114,13 @@
77114
<scope>provided</scope>
78115
<optional>true</optional>
79116
</dependency>
117+
118+
<!-- JSON. -->
119+
<dependency>
120+
<groupId>com.google.code.gson</groupId>
121+
<artifactId>gson</artifactId>
122+
<version>${gson.version}</version>
123+
<scope>test</scope>
124+
</dependency>
80125
</dependencies>
81126
</project>

src/main/java/com/mapcode/Common.java

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,6 @@
1616

1717
package com.mapcode;
1818

19-
import com.google.gson.Gson;
20-
import com.google.gson.GsonBuilder;
21-
2219
/**
2320
* ----------------------------------------------------------------------------------------------
2421
* Package private implementation class. For internal use within the Mapcode implementation only.
@@ -27,9 +24,9 @@
2724
* This class contains common data structures and methods used by the Mapcode implementation.
2825
*/
2926
class Common {
30-
public static final int[] nc = {1, 31, 961, 29791, 923521, 28629151, 887503681};
31-
public static final int[] xSide = {0, 5, 31, 168, 961, 168 * 31, 29791, 165869, 923521, 5141947};
32-
public static final int[] ySide = {0, 6, 31, 176, 961, 176 * 31, 29791, 165869, 923521, 5141947};
27+
static final int[] nc = {1, 31, 961, 29791, 923521, 28629151, 887503681};
28+
static final int[] xSide = {0, 5, 31, 168, 961, 168 * 31, 29791, 165869, 923521, 5141947};
29+
static final int[] ySide = {0, 6, 31, 176, 961, 176 * 31, 29791, 165869, 923521, 5141947};
3330
private static final int[] xDivider19 = {360, 360, 360, 360, 360, 360, 361, 361, 361, 361, 362, 362, 362, 363,
3431
363, 363, 364, 364, 365, 366, 366, 367, 367, 368, 369, 370, 370, 371, 372, 373, 374, 375, 376, 377, 378,
3532
379, 380, 382, 383, 384, 386, 387, 388, 390, 391, 393, 394, 396, 398, 399, 401, 403, 405, 407, 409, 411, 413,
@@ -39,7 +36,6 @@ class Common {
3936
805, 820, 836, 852, 869, 887, 906, 925, 946, 968, 990, 1014, 1039, 1066, 1094, 1123, 1154, 1187, 1223,
4037
1260, 1300, 1343, 1389, 1438, 1490, 1547, 1609, 1676, 1749, 1828, 1916, 2012, 2118, 2237, 2370, 2521, 2691,
4138
2887, 3114, 3380, 3696, 4077, 4547, 5139, 5910, 6952, 8443, 10747, 14784, 23681, 59485};
42-
public static final Gson GSON = new GsonBuilder().serializeSpecialFloatingPointValues().create();
4339

4440
/**
4541
* This method returns a divider for longitude (multiplied by 4), for a given latitude.
@@ -48,7 +44,7 @@ class Common {
4844
* @param maxY Longitude.
4945
* @return Divider.
5046
*/
51-
public static int xDivider(final int minY, final int maxY) {
47+
static int xDivider(final int minY, final int maxY) {
5248
if (minY >= 0) {
5349
// maxY > minY > 0
5450
return xDivider19[minY >> 19];
@@ -61,7 +57,7 @@ public static int xDivider(final int minY, final int maxY) {
6157
return xDivider19[(-maxY) >> 19];
6258
}
6359

64-
public static int countCityCoordinatesForCountry(final int sameCodex, final int index, final int firstCode) {
60+
static int countCityCoordinatesForCountry(final int sameCodex, final int index, final int firstCode) {
6561
final int i = getFirstNamelessRecord(sameCodex, index, firstCode);
6662
int e = index;
6763
while (Data.calcCodex(e) == sameCodex) {
@@ -71,7 +67,7 @@ public static int countCityCoordinatesForCountry(final int sameCodex, final int
7167
return e - i + 1;
7268
}
7369

74-
public static int getFirstNamelessRecord(final int sameCodex, final int index, final int firstCode) {
70+
static int getFirstNamelessRecord(final int sameCodex, final int index, final int firstCode) {
7571
int i = index;
7672
while ((i >= firstCode) && Data.isNameless(i) && (Data.calcCodex(i) == sameCodex)) {
7773
i--;

src/main/java/com/mapcode/Data.java

Lines changed: 23 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
* This class the data class for Mapcode codex items.
2828
*/
2929
class Data {
30-
public static final char[] ENCODE_CHARS = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'B', 'C', 'D', 'F',
30+
static final char[] ENCODE_CHARS = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'B', 'C', 'D', 'F',
3131
'G', 'H', 'J', 'K', 'L', 'M', 'N', 'P', 'Q', 'R', 'S', 'T', 'V', 'W', 'X', 'Y', 'Z'};
3232

3333
private int flags;
@@ -44,77 +44,79 @@ class Data {
4444
@Nullable private SubArea mapcoderRect;
4545
private boolean initialized;
4646

47-
public int getFlags() {
47+
int getFlags() {
4848
assert initialized;
4949
return flags;
5050
}
5151

52-
public int getCodex() {
52+
int getCodex() {
5353
assert initialized;
5454
return codex;
5555
}
5656

57-
public int getCodexLo() {
57+
int getCodexLo() {
5858
assert initialized;
5959
return codexLo;
6060
}
6161

62-
public int getCodexHi() {
62+
int getCodexHi() {
6363
assert initialized;
6464
return codexHi;
6565
}
6666

67-
public int getCodexLen() {
67+
int getCodexLen() {
6868
assert initialized;
6969
return codexLen;
7070
}
7171

72-
public boolean isNameless() {
72+
boolean isNameless() {
7373
assert initialized;
7474
return nameless;
7575
}
7676

77-
public boolean isUseless() {
77+
boolean isUseless() {
7878
assert initialized;
7979
return useless;
8080
}
8181

82-
public boolean isSpecialShape() {
82+
boolean isSpecialShape() {
8383
assert initialized;
8484
return specialShape;
8585
}
8686

87-
public int getPipeType() {
87+
int getPipeType() {
8888
assert initialized;
8989
return pipeType;
9090
}
9191

9292
@Nonnull
93-
public String getPipeLetter() {
93+
String getPipeLetter() {
9494
assert initialized;
95+
assert pipeLetter != null;
9596
return pipeLetter;
9697
}
9798

98-
public boolean isStarPipe() {
99+
boolean isStarPipe() {
99100
assert initialized;
100101
return starPipe;
101102
}
102103

103104
@Nonnull
104-
public SubArea getMapcoderRect() {
105+
SubArea getMapcoderRect() {
105106
assert initialized;
107+
assert mapcoderRect != null;
106108
return mapcoderRect;
107109
}
108110

109-
public Data(final int i) {
111+
Data(final int i) {
110112
dataSetup(i);
111113
}
112114

113-
public Data() {
115+
Data() {
114116
initialized = false;
115117
}
116118

117-
public void dataSetup(final int i) {
119+
void dataSetup(final int i) {
118120
flags = DataAccess.dataFlags(i);
119121
codexHi = calcCodexHi(flags);
120122
codexLo = calcCodexLo(flags);
@@ -140,25 +142,25 @@ public void dataSetup(final int i) {
140142
initialized = true;
141143
}
142144

143-
public static boolean isNameless(final int i) {
145+
static boolean isNameless(final int i) {
144146
return (DataAccess.dataFlags(i) & 64) != 0;
145147
}
146148

147-
public static boolean isSpecialShape(final int i) {
149+
static boolean isSpecialShape(final int i) {
148150
return (DataAccess.dataFlags(i) & 1024) != 0;
149151
}
150152

151-
public static int calcCodex(final int i) {
153+
static int calcCodex(final int i) {
152154
final int flags = DataAccess.dataFlags(i);
153155
return calcCodex(calcCodexHi(flags), calcCodexLo(flags));
154156
}
155157

156-
public static int calcCodexLen(final int i) {
158+
static int calcCodexLen(final int i) {
157159
final int flags = DataAccess.dataFlags(i);
158160
return calcCodexLen(calcCodexHi(flags), calcCodexLo(flags));
159161
}
160162

161-
public static boolean calcStarPipe(final int i) {
163+
static boolean calcStarPipe(final int i) {
162164
return (DataAccess.dataFlags(i) & (8 << 5)) != 0;
163165
}
164166

src/main/java/com/mapcode/DataAccess.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -77,18 +77,18 @@ private static int asUnsignedByte(final int i) {
7777
return u;
7878
}
7979

80-
public static int dataFlags(final int i) {
80+
static int dataFlags(final int i) {
8181
return asUnsignedByte((i * 20) + 16) + asUnsignedByte((i * 20) + 17) * 256;
8282
}
8383

84-
public static int asLong(final int i) {
84+
static int asLong(final int i) {
8585
return asUnsignedByte(i) +
8686
(asUnsignedByte(i + 1) << 8) +
8787
(asUnsignedByte(i + 2) << 16) +
8888
(asUnsignedByte(i + 3) << 24);
8989
}
9090

91-
public static int smartDiv(final int i) {
91+
static int smartDiv(final int i) {
9292
return asUnsignedByte((i * 20) + 18) + (asUnsignedByte((i * 20) + 19) * 256);
9393
}
9494

@@ -127,15 +127,15 @@ public static int smartDiv(final int i) {
127127
16105, 16112, 16114, 16115, 16117, 16118, 16120, 16122, 16124, 16126, 16128, 16129, 16130, 16162};
128128

129129
// / low-level routines for data access
130-
public static int dataFirstRecord(final int ccode) {
130+
static int dataFirstRecord(final int ccode) {
131131
return DATA_START[ccode];
132132
}
133133

134-
public static int dataLastRecord(final int ccode) {
134+
static int dataLastRecord(final int ccode) {
135135
return DATA_START[ccode + 1] - 1;
136136
}
137137

138-
public static int numberOfSubAreas() {
138+
static int numberOfSubAreas() {
139139
return DATA_START[DATA_START.length - 1];
140140
}
141141
}

0 commit comments

Comments
 (0)