Skip to content

Commit 9f833f3

Browse files
Merge pull request #1 in MAPCODE/mapcode-java-example from bugfix/unicode_mapcodes to master
* commit '47ba58b7e365f23b70fec399bbe3fa62a0f313ed': new examples with Unicode characters in MapCode
2 parents 8830aee + 47ba58b commit 9f833f3

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
*/
@@ -71,8 +71,8 @@ private static void exampleDecode() throws UnknownTerritoryException {
7171
final String mapcode2 = "NLD 49.4V";
7272
try {
7373
final Point p = Mapcode.decode(mapcode2);
74-
System.out.println(
75-
"Mapcode " + mapcode1 + " in territory " + territory + " represents latitude " + p.getLatDeg()
74+
System.out.println("Mapcode " + mapcode2 + " in territory "
75+
+ territory + " represents latitude " + p.getLatDeg()
7676
+ ", longitude " + p.getLonDeg());
7777
}
7878
catch (final UnknownMapcodeException ignored) {
@@ -108,6 +108,21 @@ private static void exampleDecode() throws UnknownTerritoryException {
108108
catch (final UnknownMapcodeException ignored) {
109109
System.out.println("This should never happen in this example as the Mapcode is valid.");
110110
}
111+
112+
/**
113+
* The fifth example tries to decode a valid Mapcode that contains
114+
* Unicode characters. This will succeed.
115+
*/
116+
final String mapcode5 = "JPN チナ.8チ";
117+
try {
118+
final Point p = Mapcode.decode(mapcode5);
119+
System.out.println("Mapcode " + mapcode5 + " represents latitude "
120+
+ p.getLatDeg() + ", longitude " + p.getLonDeg());
121+
} catch (final UnknownMapcodeException ignored) {
122+
System.out
123+
.println("This should never happen in this example as the Mapcode is valid.");
124+
}
125+
111126
System.out.println("");
112127
}
113128

0 commit comments

Comments
 (0)