Skip to content

Commit 47ba58b

Browse files
author
Jan Schäfer
committed
new examples with Unicode characters in MapCode
1 parent 56e76b1 commit 47ba58b

File tree

2 files changed

+20
-5
lines changed

2 files changed

+20
-5
lines changed

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
<url>http://mapcode.com</url>
2323

2424
<properties>
25-
<mapcode.version>1.0-SNAPSHOT</mapcode.version>
25+
<mapcode.version>1.33.1</mapcode.version>
2626
<log4j.version>1.2.17</log4j.version>
2727
<slf4j.version>1.7.2</slf4j.version>
2828
</properties>

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

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616

1717
package com.mapcode.example;
1818

19+
import java.util.List;
20+
1921
import com.mapcode.Mapcode;
2022
import com.mapcode.MapcodeInfo;
2123
import com.mapcode.ParentTerritory;
@@ -24,8 +26,6 @@
2426
import com.mapcode.UnknownMapcodeException;
2527
import com.mapcode.UnknownTerritoryException;
2628

27-
import java.util.List;
28-
2929
/**
3030
* This class serves as an example of how to use the Mapcode Java library.
3131
*/
@@ -70,8 +70,8 @@ private static void exampleDecode() throws UnknownTerritoryException {
7070
final String mapcode2 = "NLD 49.4V";
7171
try {
7272
final Point p = Mapcode.decode(mapcode2);
73-
System.out.println(
74-
"Mapcode " + mapcode1 + " in territory " + territory + " represents latitude " + p.getLatDeg()
73+
System.out.println("Mapcode " + mapcode2 + " in territory "
74+
+ territory + " represents latitude " + p.getLatDeg()
7575
+ ", longitude " + p.getLonDeg());
7676
}
7777
catch (final UnknownMapcodeException ignored) {
@@ -107,6 +107,21 @@ private static void exampleDecode() throws UnknownTerritoryException {
107107
catch (final UnknownMapcodeException ignored) {
108108
System.out.println("This should never happen in this example as the Mapcode is valid.");
109109
}
110+
111+
/**
112+
* The fifth example tries to decode a valid Mapcode that contains
113+
* Unicode characters. This will succeed.
114+
*/
115+
final String mapcode5 = "JPN チナ.8チ";
116+
try {
117+
final Point p = Mapcode.decode(mapcode5);
118+
System.out.println("Mapcode " + mapcode5 + " represents latitude "
119+
+ p.getLatDeg() + ", longitude " + p.getLonDeg());
120+
} catch (final UnknownMapcodeException ignored) {
121+
System.out
122+
.println("This should never happen in this example as the Mapcode is valid.");
123+
}
124+
110125
System.out.println("");
111126
}
112127

0 commit comments

Comments
 (0)