Skip to content

Commit 2f12d17

Browse files
committed
Merge pull request #1 from mapcode-foundation/dev-1.50
Move dev-1.50 to master
2 parents b40b440 + 8ff3404 commit 2f12d17

File tree

5 files changed

+97
-44
lines changed

5 files changed

+97
-44
lines changed

NOTICE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
Original C library created by Pieter Geelen. Work on Java version
2-
of the Mapcode library by Rijn Buve and Matthew Lowden.
2+
of the Mapcode library by Rijn Buve (original port by Matthew Lowden).
33

44
Copyright (C) 2014-2015 Stichting Mapcode Foundation (http://www.mapcode.com)

README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,13 @@ For more information, see: http://www.mapcode.com.
1919

2020
## Release Notes
2121

22+
* 1.50.0.0
23+
24+
Updated to Mapcode Java Library version 1.50.0.
25+
2226
* 1.40.2
2327

24-
Updated to version Mapcode Java Library 1.40.2.
28+
Updated to Mapcode Java Library version 1.40.2.
2529

2630
* 1.40
2731

pom.xml

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<groupId>com.mapcode</groupId>
77
<artifactId>mapcode-example</artifactId>
88
<packaging>jar</packaging>
9-
<version>1.42</version>
9+
<version>1.50.0.0</version>
1010

1111
<name>Mapcode Java Example</name>
1212
<description>
@@ -25,18 +25,34 @@
2525
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
2626
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
2727

28-
<mapcode.version>1.42.2</mapcode.version>
28+
<mapcode.version>1.50.0</mapcode.version>
2929
<log4j.version>1.2.17</log4j.version>
3030
<slf4j.version>1.7.12</slf4j.version>
3131
</properties>
3232

3333
<dependencies>
34-
35-
<!-- Mapcode Library. -->
3634
<dependency>
3735
<groupId>com.mapcode</groupId>
3836
<artifactId>mapcode</artifactId>
3937
<version>${mapcode.version}</version>
4038
</dependency>
39+
40+
<dependency>
41+
<groupId>log4j</groupId>
42+
<artifactId>log4j</artifactId>
43+
<version>${log4j.version}</version>
44+
</dependency>
45+
46+
<dependency>
47+
<groupId>org.slf4j</groupId>
48+
<artifactId>slf4j-api</artifactId>
49+
<version>${slf4j.version}</version>
50+
</dependency>
51+
52+
<dependency>
53+
<groupId>org.slf4j</groupId>
54+
<artifactId>slf4j-log4j12</artifactId>
55+
<version>${slf4j.version}</version>
56+
</dependency>
4157
</dependencies>
4258
</project>

src/main/java/com/mapcode/example/Example.java

Lines changed: 29 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,7 @@
1616

1717
package com.mapcode.example;
1818

19-
import com.mapcode.Mapcode;
20-
import com.mapcode.MapcodeCodec;
21-
import com.mapcode.ParentTerritory;
22-
import com.mapcode.Point;
23-
import com.mapcode.Territory;
24-
import com.mapcode.UnknownMapcodeException;
25-
import com.mapcode.UnknownTerritoryException;
19+
import com.mapcode.*;
2620

2721
import java.util.List;
2822

@@ -32,6 +26,10 @@
3226
@SuppressWarnings("UseOfSystemOutOrSystemErr")
3327
public class Example {
3428

29+
private Example() {
30+
// Empty.
31+
}
32+
3533
/**
3634
* Main method.
3735
*
@@ -57,10 +55,9 @@ private static void exampleDecode() throws UnknownTerritoryException {
5755
try {
5856
final Point p = MapcodeCodec.decode(mapcode1, territory);
5957
System.out.println("Mapcode " + mapcode1 + " in territory " + territory + " represents latitude " + p
60-
.getLatDeg() + ", " +
61-
"longitude " + p.getLonDeg());
62-
}
63-
catch (final UnknownMapcodeException ignored) {
58+
.getLatDeg() + ", " +
59+
"longitude " + p.getLonDeg());
60+
} catch (final UnknownMapcodeException ignored) {
6461
System.out.println("This should never happen in this example as the Mapcode is valid.");
6562
}
6663

@@ -72,10 +69,9 @@ private static void exampleDecode() throws UnknownTerritoryException {
7269
try {
7370
final Point p = MapcodeCodec.decode(mapcode2);
7471
System.out.println("Mapcode " + mapcode2 + " in territory "
75-
+ territory + " represents latitude " + p.getLatDeg()
76-
+ ", longitude " + p.getLonDeg());
77-
}
78-
catch (final UnknownMapcodeException ignored) {
72+
+ territory + " represents latitude " + p.getLatDeg()
73+
+ ", longitude " + p.getLonDeg());
74+
} catch (final UnknownMapcodeException ignored) {
7975
System.out.println("This should never happen in this example as the Mapcode is valid.");
8076
}
8177

@@ -87,25 +83,23 @@ private static void exampleDecode() throws UnknownTerritoryException {
8783
try {
8884
final Point p = MapcodeCodec.decode(mapcode3, territory);
8985
System.out.println(
90-
"Mapcode " + mapcode3 + " in territory " + territory + " represents latitude " + p.getLatDeg()
91-
+ ", longitude " + p.getLonDeg());
92-
}
93-
catch (final UnknownMapcodeException ignored) {
86+
"Mapcode " + mapcode3 + " in territory " + territory + " represents latitude " + p.getLatDeg()
87+
+ ", longitude " + p.getLonDeg());
88+
} catch (final UnknownMapcodeException ignored) {
9489
System.out.println("Mapcode " + mapcode3 + " in territory " + territory + " is invalid, " +
95-
"as expected in this example");
90+
"as expected in this example");
9691
}
9792

9893
/**
99-
* The fourht example tries to decode a valid international Mapcode without a territory context.
94+
* The fourth example tries to decode a valid international Mapcode without a territory context.
10095
* This will succeed.
10196
*/
10297
final String mapcode4 = "PQ0PF.5M1H";
10398
try {
10499
final Point p = MapcodeCodec.decode(mapcode4);
105100
System.out.println(
106-
"Mapcode " + mapcode4 + " represents latitude " + p.getLatDeg() + ", longitude " + p.getLonDeg());
107-
}
108-
catch (final UnknownMapcodeException ignored) {
101+
"Mapcode " + mapcode4 + " represents latitude " + p.getLatDeg() + ", longitude " + p.getLonDeg());
102+
} catch (final UnknownMapcodeException ignored) {
109103
System.out.println("This should never happen in this example as the Mapcode is valid.");
110104
}
111105

@@ -117,11 +111,10 @@ private static void exampleDecode() throws UnknownTerritoryException {
117111
try {
118112
final Point p = MapcodeCodec.decode(mapcode5);
119113
System.out.println("Mapcode " + mapcode5 + " represents latitude "
120-
+ p.getLatDeg() + ", longitude " + p.getLonDeg());
121-
}
122-
catch (final UnknownMapcodeException ignored) {
114+
+ p.getLatDeg() + ", longitude " + p.getLonDeg());
115+
} catch (final UnknownMapcodeException ignored) {
123116
System.out
124-
.println("This should never happen in this example as the Mapcode is valid.");
117+
.println("This should never happen in this example as the Mapcode is valid.");
125118
}
126119

127120
System.out.println("");
@@ -142,7 +135,7 @@ private static void exampleEncode() {
142135
*/
143136
List<Mapcode> results = MapcodeCodec.encode(lat, lon);
144137
System.out.println("There are " + results.size() + " Mapcodes in total for latitude " + lat + ", " +
145-
"longitude " + lon + " world-wide");
138+
"longitude " + lon + " world-wide");
146139

147140
int count = 1;
148141
for (final Mapcode result : results) {
@@ -157,7 +150,7 @@ private static void exampleEncode() {
157150
final Territory territory = Territory.NLD;
158151
results = MapcodeCodec.encode(lat, lon, territory);
159152
System.out.println("There are " + results.size() + " Mapcodes in total for latitude " + lat + ", " +
160-
"longitude " + lon + " in " + territory.getFullName());
153+
"longitude " + lon + " in " + territory.getFullName());
161154

162155
count = 1;
163156
for (final Mapcode result : results) {
@@ -175,7 +168,7 @@ private static void exampleEncode() {
175168

176169
results = MapcodeCodec.encode(lat, lon);
177170
System.out.println("There are " + results.size() + " Mapcodes in total for latitude " + lat + ", " +
178-
"longitude " + lon + " world-wide");
171+
"longitude " + lon + " world-wide");
179172
count = 1;
180173
for (final Mapcode result : results) {
181174
System.out.println(" #" + count + ": " + result);
@@ -190,8 +183,7 @@ private static void exampleEncode() {
190183
results = MapcodeCodec.encode(0, 0, territory);
191184
if (results.isEmpty()) {
192185
System.out.println(" No Mapcode results found, as expected in this example");
193-
}
194-
else {
186+
} else {
195187
System.out.println("This should never happen in this example.");
196188
}
197189
System.out.println("");
@@ -226,18 +218,17 @@ private static void exampleDisambiguateTerritory() throws UnknownTerritoryExcept
226218

227219
// Disambiguation using a correct parent territory context.
228220
System.out.println("ISO code " + isoCode + " in USA context : " +
229-
Territory.fromString(isoCode, ParentTerritory.USA).toString());
221+
Territory.fromString(isoCode, ParentTerritory.USA).toString());
230222
System.out.println("ISO code " + isoCode + " in IND context : " +
231-
Territory.fromString(isoCode, ParentTerritory.IND).toString());
223+
Territory.fromString(isoCode, ParentTerritory.IND).toString());
232224

233225
// Disambiguation using an incorrect parent territory context, which does not contains the state.
234226
// This call will actually fail and throw an exception because the disambiguation cannot be
235227
// completed.
236228
try {
237229
System.out.println("ISO code " + isoCode + " in RUS context : " + Territory.fromString(isoCode,
238-
ParentTerritory.RUS).toString());
239-
}
240-
catch (final UnknownTerritoryException ignored) {
230+
ParentTerritory.RUS).toString());
231+
} catch (final UnknownTerritoryException ignored) {
241232
System.out.println("ISO code " + isoCode + " in RUS context : failed (as expected in this example)");
242233
}
243234
System.out.println("");

src/main/resources/log4j.xml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
<?xml version="1.0" encoding="UTF-8" ?>
2+
<!--
3+
~ Copyright (C) 2014-2015 Stichting Mapcode Foundation (http://www.mapcode.com)
4+
~
5+
~ Licensed under the Apache License, Version 2.0 (the "License");
6+
~ you may not use this file except in compliance with the License.
7+
~ You may obtain a copy of the License at
8+
~
9+
~ http://www.apache.org/licenses/LICENSE-2.0
10+
~
11+
~ Unless required by applicable law or agreed to in writing, software
12+
~ distributed under the License is distributed on an "AS IS" BASIS,
13+
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
~ See the License for the specific language governing permissions and
15+
~ limitations under the License.
16+
-->
17+
18+
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
19+
20+
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
21+
<appender name="console" class="org.apache.log4j.ConsoleAppender">
22+
<param name="Target" value="System.out"/>
23+
<layout class="org.apache.log4j.PatternLayout">
24+
<param name="ConversionPattern" value="# %d{yyyy-MM-dd HH:mm:ss.SSS} [%-5p] %22.22t | %42.42c | %m%n"/>
25+
</layout>
26+
</appender>
27+
28+
<!-- Make sure we get all messages from our own domain. -->
29+
<logger name="com.mapcode">
30+
<level value="info"/>
31+
</logger>
32+
33+
<!--
34+
Define the root (default) logging level. Set it to "warn" to avoid
35+
getting debug and info messages from 3rd party products.
36+
-->
37+
38+
<root>
39+
<priority value="warn"/>
40+
<appender-ref ref="console"/>
41+
</root>
42+
</log4j:configuration>

0 commit comments

Comments
 (0)