diff --git a/.gitignore b/.gitignore index 19ba0e5..bd7e011 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ target/ out/ *.versionsBackup +.gitnexus diff --git a/.travis.yml b/.travis.yml index f13cefa..0bbf7f3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,7 +3,7 @@ language: java sudo: false jdk: - - oraclejdk8 + - openjdk8 install: - export JAVA_TOOL_OPTIONS="-Dfile.encoding=UTF8" diff --git a/LICENSE b/LICENSE index d645695..0f28414 100644 --- a/LICENSE +++ b/LICENSE @@ -176,18 +176,7 @@ END OF TERMS AND CONDITIONS - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright [yyyy] [name of copyright owner] + Copyright 2019, Stichting Mapcode Foundation Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/NOTICE b/NOTICE index 238ceb3..5c88d0b 100644 --- a/NOTICE +++ b/NOTICE @@ -5,4 +5,4 @@ MAPCODE JAVA LIBRARY Original C library created by Pieter Geelen. Work on Java version of the Mapcode library by Rijn Buve (original port by Matthew Lowden). -Copyright (C) 2014-2017, Stichting Mapcode Foundation (http://www.mapcode.com) +Copyright (C) 2014-2019, Stichting Mapcode Foundation (http://www.mapcode.com) diff --git a/README.md b/README.md index 50e72ca..04fb346 100644 --- a/README.md +++ b/README.md @@ -1,13 +1,11 @@ # Mapcode Library for Java -[![Codacy Badge](https://api.codacy.com/project/badge/Grade/0c9f11645f504b50bd154a80fb95a5c3)](https://www.codacy.com/app/rijnb/mapcode-java?utm_source=github.com&utm_medium=referral&utm_content=mapcode-foundation/mapcode-java&utm_campaign=Badge_Grade) -[![Build Status](https://img.shields.io/travis/mapcode-foundation/mapcode-java.svg?maxAge=3600&branch=master)](https://travis-ci.org/mapcode-foundation/mapcode-java) [![Coverage Status](https://coveralls.io/repos/github/mapcode-foundation/mapcode-java/badge.svg?branch=master&maxAge=3600)](https://coveralls.io/github/mapcode-foundation/mapcode-java?branch=master) [![License](http://img.shields.io/badge/license-APACHE2-blue.svg)]() [![Release](https://img.shields.io/github/release/mapcode-foundation/mapcode-java.svg?maxAge=3600)](https://github.com/mapcode-foundation/mapcode-java/releases) [![Maven Central](https://img.shields.io/maven-central/v/com.mapcode/mapcode.svg?maxAge=3600)](https://maven-badges.herokuapp.com/maven-central/com.mapcode/mapcode) -**Copyright (C) 2014-2017, Stichting Mapcode Foundation (http://www.mapcode.com)** +**Copyright (C) 2014-2026, Stichting Mapcode Foundation (http://www.mapcode.com)** This Java project contains a library to encode latitude/longitude pairs to mapcodes and to decode mapcodes back to latitude/longitude pairs. @@ -480,6 +478,53 @@ Normally, one of our developers should be able to comment on them and fix. These are the release notes for the Java library for mapcodes. +### 2.4.19 + +* Added synonyms for territories Maco CN-MO and Mexico MX-CMX. +* Updated dependencies. + +### 2.4.16-2.4.18 + +* Updated `log4j` and `gson` dependencies. + +### 2.4.15 + +* Removed country code ANT (not used for mapcodes) after JDK 1.8. Fixed unit test for that. + +* Updated Maven dependencies for security vulnerabilities. + +* Updated copyrights. + +### 2.4.14 + +* Updated dependencies for security vulnerabilities. + +### 2.4.13 + +* Minor code cleanup. + +### 2.4.12 + +* Added unit tests to check internal data structures. + +### 2.4.11 + +* Fixed a bug in `Mapcode.isValidMapcodeFormat()` which caused an exception when parsing a Unicode mapcode +which included a numeral, like `THA จก.ผถฉ๕` (which is `THA GB.RMH5` in non-Unicode). + +### 2.4.10 + +* Changed `Mapcode.isValidMapcodeFormat()` to return `false` if the string is `null`. Trimming the string is also +no longer needed. + +### 2.4.9 + +* Updated dependencies for security patches. + +### 2.4.8 + +* Updated dependencies for security patches. + ### 2.4.7 * Added `fromCountryISO/2/3` methods to get a `Territory` value from a 2- or 3-character ISO 3166 string. diff --git a/pom.xml b/pom.xml index c177797..a2b93fc 100644 --- a/pom.xml +++ b/pom.xml @@ -1,3 +1,19 @@ + + = 0) { diff --git a/src/main/java/com/mapcode/Data.java b/src/main/java/com/mapcode/Data.java index 36f28cf..2eb7e37 100644 --- a/src/main/java/com/mapcode/Data.java +++ b/src/main/java/com/mapcode/Data.java @@ -1,11 +1,11 @@ /* - * Copyright (C) 2014-2017, Stichting Mapcode Foundation (http://www.mapcode.com) + * Copyright (C) 2016-2021, Stichting Mapcode Foundation (http://www.mapcode.com) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, diff --git a/src/main/java/com/mapcode/DataModel.java b/src/main/java/com/mapcode/DataModel.java index 5b0252a..72a8543 100644 --- a/src/main/java/com/mapcode/DataModel.java +++ b/src/main/java/com/mapcode/DataModel.java @@ -1,11 +1,11 @@ /* - * Copyright (C) 2014-2017, Stichting Mapcode Foundation (http://www.mapcode.com) + * Copyright (C) 2016-2021, Stichting Mapcode Foundation (http://www.mapcode.com) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, @@ -86,7 +86,7 @@ private static int readLongLoHi(final int lo, final int mid1, final int mid2, fi private static final Object mutex = new Object(); @SuppressWarnings({"DoubleCheckedLocking", "SynchronizationOnStaticField"}) - public static DataModel getInstance() { + static DataModel getInstance() { if (instance == null) { synchronized (mutex) { if (instance == null) { diff --git a/src/main/java/com/mapcode/Decoder.java b/src/main/java/com/mapcode/Decoder.java index de46cb5..195ad2e 100644 --- a/src/main/java/com/mapcode/Decoder.java +++ b/src/main/java/com/mapcode/Decoder.java @@ -1,11 +1,11 @@ /* - * Copyright (C) 2014-2017, Stichting Mapcode Foundation (http://www.mapcode.com) + * Copyright (C) 2016-2021, Stichting Mapcode Foundation (http://www.mapcode.com) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, @@ -205,7 +205,7 @@ static MapcodeZone decodeToMapcodeZone(@Nonnull final String argMapcode, // Private methods. // ---------------------------------------------------------------------- - private final static int[] DECODE_CHARS = { + final static int[] DECODE_CHARS = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, @@ -224,7 +224,7 @@ static MapcodeZone decodeToMapcodeZone(@Nonnull final String argMapcode, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }; - private static class Unicode2Ascii { + static class Unicode2Ascii { final char min; final char max; @@ -245,7 +245,7 @@ private static class Unicode2Ascii { private static final char MISSCODE = '?'; // @formatter:off - @SuppressWarnings("LongLine") private final static char[][] ASCII2LANGUAGE = { + @SuppressWarnings("LongLine") final static char[][] ASCII2LANGUAGE = { // Character: A B C D E F G H I J K L M N O P Q R S T U V W X Y Z 0 1 2 3 4 5 6 7 8 9 /* Roman */ {'\u0041', '\u0042', '\u0043', '\u0044', '\u0045', '\u0046', '\u0047', '\u0048', '\u0049', '\u004a', '\u004b', '\u004c', '\u004d', '\u004e', '\u004f', '\u0050', '\u0051', '\u0052', '\u0053', '\u0054', '\u0055', '\u0056', '\u0057', '\u0058', '\u0059', '\u005a', '\u0030', '\u0031', '\u0032', '\u0033', '\u0034', '\u0035', '\u0036', '\u0037', '\u0038', '\u0039'}, // Roman /* Greek */ {'\u0391', '\u0392', '\u039e', '\u0394', '\u0388', '\u0395', '\u0393', '\u0397', '\u0399', '\u03a0', '\u039a', '\u039b', '\u039c', '\u039d', '\u039f', '\u03a1', '\u0398', '\u03a8', '\u03a3', '\u03a4', '\u0389', '\u03a6', '\u03a9', '\u03a7', '\u03a5', '\u0396', '\u0030', '\u0031', '\u0032', '\u0033', '\u0034', '\u0035', '\u0036', '\u0037', '\u0038', '\u0039'}, // Greek @@ -279,7 +279,7 @@ private static class Unicode2Ascii { // @formatter:on // @formatter:off - @SuppressWarnings("LongLine") private final static Unicode2Ascii[] UNICODE2ASCII = { + @SuppressWarnings("LongLine") final static Unicode2Ascii[] UNICODE2ASCII = { /* Roman */ new Unicode2Ascii('\u0041', '\u005a', "ABCDEFGHIJKLMNOPQRSTUVWXYZ"), // Roman /* Greek */ new Unicode2Ascii('\u0388', '\u03a9', "EU???????ABGDFZHQIKLMNCOJP?STYVXRW"), // Greek /* Cyrillic */ new Unicode2Ascii('\u0410', '\u042f', "AZBGDEFNI?KLMHOJPCTYQXSVW????U?R"), // Cyrillic @@ -296,15 +296,15 @@ private static class Unicode2Ascii { /* Tibetan */ new Unicode2Ascii('\u0f40', '\u0f66', "BCD?FGHJ?K?????NMP?QRLS?A?????TVUWXYE?Z"), // Tibetan /* Arabic */ new Unicode2Ascii('\u0627', '\u0648', "IA?BEVCDFGHJKLMNPQRS??????TU?WXYOZ"), // Arabic - /* Devanag. */ new Unicode2Ascii('\u0966', '\u096f', ""), // Devanagari digits - /* Malai */ new Unicode2Ascii('\u0d66', '\u0d6f', ""), // Malayalam digits - /* Thai */ new Unicode2Ascii('\u0e50', '\u0e59', ""), // Thai digits - /* Bengali */ new Unicode2Ascii('\u09e6', '\u09ef', ""), // Bengali digits - /* Gurmukhi */ new Unicode2Ascii('\u0a66', '\u0a6f', ""), // Gurmukhi digits - /* Tibetan */ new Unicode2Ascii('\u0f20', '\u0f29', ""), // Tibetan digits - /* Burmese */ new Unicode2Ascii('\u1040', '\u1049', ""), // Burmese digits - /* Khmer */ new Unicode2Ascii('\u17e0', '\u17e9', ""), // Khmer digits - /* Tamil */ new Unicode2Ascii('\u0be6', '\u0bef', ""), // Tamil digits + /* Devanag. */ new Unicode2Ascii('\u0966', '\u096f', "0123456789"), // Devanagari digits + /* Malai */ new Unicode2Ascii('\u0d66', '\u0d6f', "0123456789"), // Malayalam digits + /* Thai */ new Unicode2Ascii('\u0e50', '\u0e59', "0123456789"), // Thai digits + /* Bengali */ new Unicode2Ascii('\u09e6', '\u09ef', "0123456789"), // Bengali digits + /* Gurmukhi */ new Unicode2Ascii('\u0a66', '\u0a6f', "0123456789"), // Gurmukhi digits + /* Tibetan */ new Unicode2Ascii('\u0f20', '\u0f29', "0123456789"), // Tibetan digits + /* Burmese */ new Unicode2Ascii('\u1040', '\u1049', "0123456789"), // Burmese digits + /* Khmer */ new Unicode2Ascii('\u17e0', '\u17e9', "0123456789"), // Khmer digits + /* Tamil */ new Unicode2Ascii('\u0be6', '\u0bef', "0123456789"), // Tamil digits /* Amharic */ new Unicode2Ascii('\u1369', '\u1372', "1234567890"), // Amharic digits [1-9][0] /* Korean */ new Unicode2Ascii('\u1100', '\u1175', "B?CD?F?G?H?OV?WXJKA??????????????????????????????????????????????????????????????????????????????LMNPQER?S???YZ???T?UI"), // Korean @@ -678,6 +678,7 @@ private static String aeuUnpack(@Nonnull final String argStr) { for (int v = 0; v <= lastpos; v++) { if (v != dotpos) { + //noinspection RedundantCast final int i = (int) str.charAt(v); if (DECODE_CHARS[i] < 0) { return ""; // bad char! @@ -728,7 +729,7 @@ static String decodeUTF16(@Nonnull final String mapcode) { if (mapcode.startsWith(String.valueOf(GREEK_CAPITAL_ALPHA))) { final String unpacked = aeuUnpack(result); if (unpacked.isEmpty()) { - throw new AssertionError("decodeUTF16: cannot decode " + mapcode); + throw new UnknownDecodeException("decodeUTF16: cannot decode " + mapcode); } result = Encoder.aeuPack(unpacked, false); } @@ -839,7 +840,9 @@ private static MapcodeZone decodeExtension( final int extremeLatMicroDeg, final int maxLonMicroDeg) { final MapcodeZone mapcodeZone = new MapcodeZone(); + //noinspection RedundantCast double dividerx4 = (double) dividerx0; + //noinspection RedundantCast double dividery = (double) dividery0; double processor = 1; int lon32 = 0; @@ -849,6 +852,7 @@ private static MapcodeZone decodeExtension( // decode up to 8 characters final int len = (extrapostfix.length() > 8) ? 8 : extrapostfix.length(); while (idx < len) { + //noinspection RedundantCast int c1 = (int) extrapostfix.charAt(idx); idx++; c1 = DECODE_CHARS[c1]; @@ -861,6 +865,7 @@ private static MapcodeZone decodeExtension( final int y2; final int x2; if (idx < len) { + //noinspection RedundantCast int c2 = (int) extrapostfix.charAt(idx); idx++; c2 = DECODE_CHARS[c2]; @@ -915,6 +920,7 @@ private static MapcodeZone decodeExtension( private static boolean isAbjadScript(@Nonnull final String argStr) { for (final char ch : argStr.toCharArray()) { + //noinspection RedundantCast final int c = (int) ch; if ((c >= 0x0628) && (c <= 0x0649)) { return true; // Arabic diff --git a/src/main/java/com/mapcode/Encoder.java b/src/main/java/com/mapcode/Encoder.java index 6c3cbf9..8f2f459 100644 --- a/src/main/java/com/mapcode/Encoder.java +++ b/src/main/java/com/mapcode/Encoder.java @@ -1,11 +1,11 @@ /* - * Copyright (C) 2014-2017, Stichting Mapcode Foundation (http://www.mapcode.com) + * Copyright (C) 2016-2021, Stichting Mapcode Foundation (http://www.mapcode.com) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, @@ -338,8 +338,7 @@ private static String encodeAutoHeader( if (Data.getTerritoryRecordType(i) == Data.TERRITORY_RECORD_TYPE_PLUS) // plus pipe { final int goodRounder = (codexm >= 23) ? (961 * 961 * 31) : (961 * 961); - product = - ((((storageStart + product + goodRounder) - 1) / goodRounder) * goodRounder) - storageStart; + product = ((((storageStart + product + goodRounder) - 1) / goodRounder) * goodRounder) - storageStart; } if (i == territoryRecord) { diff --git a/src/main/java/com/mapcode/IncorrectDataModelException.java b/src/main/java/com/mapcode/IncorrectDataModelException.java index 2872204..dd7f410 100644 --- a/src/main/java/com/mapcode/IncorrectDataModelException.java +++ b/src/main/java/com/mapcode/IncorrectDataModelException.java @@ -1,11 +1,11 @@ /* - * Copyright (C) 2014-2017, Stichting Mapcode Foundation (http://www.mapcode.com) + * Copyright (C) 2016-2021, Stichting Mapcode Foundation (http://www.mapcode.com) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, diff --git a/src/main/java/com/mapcode/Mapcode.java b/src/main/java/com/mapcode/Mapcode.java index e0e4c96..e32a310 100644 --- a/src/main/java/com/mapcode/Mapcode.java +++ b/src/main/java/com/mapcode/Mapcode.java @@ -1,11 +1,11 @@ /* - * Copyright (C) 2014-2017, Stichting Mapcode Foundation (http://www.mapcode.com) + * Copyright (C) 2016-2021, Stichting Mapcode Foundation (http://www.mapcode.com) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, @@ -23,7 +23,6 @@ import java.util.regex.Pattern; import static com.mapcode.CheckArgs.checkMapcodeCode; -import static com.mapcode.CheckArgs.checkNonnull; /** * This class defines a single mapcode encoding result, including the alphanumeric code and the @@ -250,13 +249,13 @@ public Territory getTerritory() { * provided as statics to only compile these patterns once. */ @Nonnull - static final String REGEX_TERRITORY = "[\\p{L}\\p{N}]{2,3}+([-_][\\p{L}\\p{N}]{2,3}+)?"; + private static final String REGEX_TERRITORY = "[\\p{L}\\p{N}]{2,3}+([-_][\\p{L}\\p{N}]{2,3}+)?"; @Nonnull - static final String REGEX_CODE_PREFIX = "[\\p{L}\\p{N}]{2,5}+"; + private static final String REGEX_CODE_PREFIX = "[\\p{L}\\p{N}]{2,5}+"; @Nonnull - static final String REGEX_CODE_POSTFIX = "[\\p{L}\\p{N}]{2,4}+"; + private static final String REGEX_CODE_POSTFIX = "[\\p{L}\\p{N}]{2,4}+"; @Nonnull - static final String REGEX_CODE_PRECISION = "[-][\\p{L}\\p{N}&&[^zZ]]{1,8}+"; + private static final String REGEX_CODE_PRECISION = "[-][\\p{L}\\p{N}&&[^zZ]]{1,8}+"; /** * This patterns/regular expressions is used for checking mapcode format strings. @@ -313,14 +312,18 @@ public static int getPrecisionFormat(@Nonnull final String mapcode) throws Unkno * actually a valid mapcode representing a location on Earth. * @throws IllegalArgumentException If mapcode is null. */ - public static boolean isValidMapcodeFormat(@Nonnull final String mapcode) throws IllegalArgumentException { - checkNonnull("mapcode", mapcode); + public static boolean isValidMapcodeFormat(@Nullable final String mapcode) throws IllegalArgumentException { + if (mapcode == null) { + return false; + } try { // Throws an exception if the format is incorrect. - getPrecisionFormat(mapcode.toUpperCase()); + getPrecisionFormat(mapcode.trim().toUpperCase()); return true; } catch (final UnknownPrecisionFormatException ignored) { return false; + } catch (final UnknownDecodeException ignored2) { + return false; } } @@ -333,7 +336,7 @@ public static boolean isValidMapcodeFormat(@Nonnull final String mapcode) throws */ public static boolean containsTerritory(@Nonnull final String mapcode) throws IllegalArgumentException { checkMapcodeCode("mapcode", mapcode); - return PATTERN_TERRITORY.matcher(mapcode.toUpperCase().trim()).find(); + return PATTERN_TERRITORY.matcher(mapcode.trim().toUpperCase()).find(); } /** diff --git a/src/main/java/com/mapcode/MapcodeCodec.java b/src/main/java/com/mapcode/MapcodeCodec.java index 4a32ed8..b0e3405 100644 --- a/src/main/java/com/mapcode/MapcodeCodec.java +++ b/src/main/java/com/mapcode/MapcodeCodec.java @@ -1,11 +1,11 @@ /* - * Copyright (C) 2014-2017, Stichting Mapcode Foundation (http://www.mapcode.com) + * Copyright (C) 2016-2021, Stichting Mapcode Foundation (http://www.mapcode.com) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, @@ -416,6 +416,7 @@ public static boolean isNearMultipleBorders(@Nonnull final Point point, @Nonnull return false; } + @SuppressWarnings("OverlyBroadThrowsClause") @Nonnull private static MapcodeZone decodeToMapcodeZone(@Nonnull final String mapcode, @Nullable final Territory defaultTerritoryContext) throws UnknownMapcodeException, IllegalArgumentException { diff --git a/src/main/java/com/mapcode/MapcodeZone.java b/src/main/java/com/mapcode/MapcodeZone.java index 1d8e39c..29300c4 100644 --- a/src/main/java/com/mapcode/MapcodeZone.java +++ b/src/main/java/com/mapcode/MapcodeZone.java @@ -1,11 +1,11 @@ /* - * Copyright (C) 2014-2017, Stichting Mapcode Foundation (http://www.mapcode.com) + * Copyright (C) 2016-2021, Stichting Mapcode Foundation (http://www.mapcode.com) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, diff --git a/src/main/java/com/mapcode/Point.java b/src/main/java/com/mapcode/Point.java index 07e939c..7544446 100644 --- a/src/main/java/com/mapcode/Point.java +++ b/src/main/java/com/mapcode/Point.java @@ -1,11 +1,11 @@ /* - * Copyright (C) 2014-2017, Stichting Mapcode Foundation (http://www.mapcode.com) + * Copyright (C) 2016-2021, Stichting Mapcode Foundation (http://www.mapcode.com) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, @@ -36,9 +36,13 @@ public final class Point { // Latitude and longitude ranges. + @SuppressWarnings("unused") public static final double LON_DEG_MIN = -180.0; + @SuppressWarnings("unused") public static final double LON_DEG_MAX = 180.0; + @SuppressWarnings("unused") public static final double LAT_DEG_MIN = -90.0; + @SuppressWarnings("unused") public static final double LAT_DEG_MAX = 90.0; // Conversion constants. diff --git a/src/main/java/com/mapcode/Rectangle.java b/src/main/java/com/mapcode/Rectangle.java index ccb71a7..4eebac9 100644 --- a/src/main/java/com/mapcode/Rectangle.java +++ b/src/main/java/com/mapcode/Rectangle.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2016-2017, Stichting Mapcode Foundation (http://www.mapcode.com) + * Copyright (C) 2016-2021, Stichting Mapcode Foundation (http://www.mapcode.com) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/mapcode/Territory.java b/src/main/java/com/mapcode/Territory.java index ced21ab..5f4879f 100644 --- a/src/main/java/com/mapcode/Territory.java +++ b/src/main/java/com/mapcode/Territory.java @@ -1,11 +1,11 @@ /* - * Copyright (C) 2014-2017, Stichting Mapcode Foundation (http://www.mapcode.com) + * Copyright (C) 2016-2021, Stichting Mapcode Foundation (http://www.mapcode.com) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, @@ -48,7 +48,7 @@ public enum Territory { BLM(5, "Saint-Barthelemy"), NRU(6, "Nauru"), TUV(7, "Tuvalu"), - MAC(8, "Macau", new Alphabet[]{Alphabet.CHINESE, Alphabet.ROMAN}, null, new String[]{"CN-92", "CHN-92", "CN-MC", "CHN-MC"}, new String[]{"Aomen"}), + MAC(8, "Macau", new Alphabet[]{Alphabet.CHINESE, Alphabet.ROMAN}, null, new String[]{"CN-92", "CHN-92", "CN-MC", "CHN-MC", "CN-MO", "CHN-MO"}, new String[]{"Aomen"}), SXM(9, "Sint Maarten"), MAF(10, "Saint-Martin"), NFK(11, "Norfolk and Philip Island", null, null, new String[]{"AU-NF", "AUS-NF"}, @@ -277,7 +277,7 @@ public enum Territory { LBY(230, "Libya", new Alphabet[]{Alphabet.ARABIC, Alphabet.ROMAN, Alphabet.TIFINAGH}), SDN(231, "Sudan", new Alphabet[]{Alphabet.ARABIC, Alphabet.ROMAN}), IDN(232, "Indonesia"), - MX_DIF(233, "Federal District", null, MEX, new String[]{"MX-DF"}), + MX_DIF(233, "Federal District", null, MEX, new String[]{"MX-DF", "MX-CMX"}), MX_TLA(234, "Tlaxcala", null, MEX, new String[]{"MX-TL"}), MX_MOR(235, "Morelos", null, MEX, new String[]{"MX-MO"}), MX_AGU(236, "Aguascalientes", null, MEX, new String[]{"MX-AG"}), @@ -960,14 +960,15 @@ public boolean hasSubdivisions() { // Add Clipperton Island (not recognized by Java). MAP_ISO3_TO_ISO2.put("CPT", "CP"); + // Remove Antilles (present in Java 1.8, removed later). + MAP_ISO3_TO_ISO2.remove("ANT"); + // Create fixed sets of the keys and values. COUNTRY_ISO2_CODES = new HashSet(MAP_ISO3_TO_ISO2.values()); COUNTRY_ISO3_CODES = new HashSet(MAP_ISO3_TO_ISO2.keySet()); } - /** - * Static checking of the static data structures. - */ + // Static checking of the static data structures. static { final String errorPrefix = "Initializing error: "; CODE_LIST = new ArrayList(); @@ -978,11 +979,11 @@ public boolean hasSubdivisions() { final Set territoryNumbers = new HashSet(); final Set namesSet = new HashSet(); - for (final Territory territory : Territory.values()) { + for (final Territory territory : values()) { final int territoryNumber = territory.getNumber(); // Check if territory code is within range. - if ((territoryNumber < 0) || (territoryNumber >= Territory.values().length)) { + if ((territoryNumber < 0) || (territoryNumber >= values().length)) { throw new ExceptionInInitializerError(errorPrefix + "territory number out of range: " + territoryNumber); } @@ -1036,12 +1037,12 @@ public boolean hasSubdivisions() { max = Math.max(max, territory.number); assert territory.alphabets.length > 0; } - assert territoryNumbers.size() == Territory.values().length; + assert territoryNumbers.size() == values().length; // Check that territory has at least one alphabet. // Check for missing codes; minimum code must be 0, maximum code must be last code of enum. - if (!((min == 0) && (max == (Territory.values().length - 1)))) { + if (!((min == 0) && (max == (values().length - 1)))) { throw new ExceptionInInitializerError(errorPrefix + "incorrect min/max territory number: " + min + '/' + max); } } diff --git a/src/main/java/com/mapcode/UnknownAlphabetException.java b/src/main/java/com/mapcode/UnknownAlphabetException.java index fcf332e..0519e78 100644 --- a/src/main/java/com/mapcode/UnknownAlphabetException.java +++ b/src/main/java/com/mapcode/UnknownAlphabetException.java @@ -1,11 +1,11 @@ /* - * Copyright (C) 2014-2017, Stichting Mapcode Foundation (http://www.mapcode.com) + * Copyright (C) 2016-2021, Stichting Mapcode Foundation (http://www.mapcode.com) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, diff --git a/src/main/java/com/mapcode/UnknownDecodeException.java b/src/main/java/com/mapcode/UnknownDecodeException.java new file mode 100644 index 0000000..ef38c63 --- /dev/null +++ b/src/main/java/com/mapcode/UnknownDecodeException.java @@ -0,0 +1,32 @@ +/* + * Copyright (C) 2016-2021, Stichting Mapcode Foundation (http://www.mapcode.com) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.mapcode; + +import javax.annotation.Nonnull; + +/** + * This runtime exception is thrown is decoding fails for an unknown reason. + * The exception is not exposed externally. + */ +final class UnknownDecodeException extends IllegalStateException { + private static final long serialVersionUID = 1L; + + UnknownDecodeException(@Nonnull final String message) { + super(message); + assert message != null; + } +} diff --git a/src/main/java/com/mapcode/UnknownMapcodeException.java b/src/main/java/com/mapcode/UnknownMapcodeException.java index ad39916..2bd7a24 100644 --- a/src/main/java/com/mapcode/UnknownMapcodeException.java +++ b/src/main/java/com/mapcode/UnknownMapcodeException.java @@ -1,11 +1,11 @@ /* - * Copyright (C) 2014-2017, Stichting Mapcode Foundation (http://www.mapcode.com) + * Copyright (C) 2016-2021, Stichting Mapcode Foundation (http://www.mapcode.com) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, diff --git a/src/main/java/com/mapcode/UnknownPrecisionFormatException.java b/src/main/java/com/mapcode/UnknownPrecisionFormatException.java index 01d86a4..732610e 100644 --- a/src/main/java/com/mapcode/UnknownPrecisionFormatException.java +++ b/src/main/java/com/mapcode/UnknownPrecisionFormatException.java @@ -1,11 +1,11 @@ /* - * Copyright (C) 2014-2017, Stichting Mapcode Foundation (http://www.mapcode.com) + * Copyright (C) 2016-2021, Stichting Mapcode Foundation (http://www.mapcode.com) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, diff --git a/src/main/java/com/mapcode/UnknownTerritoryException.java b/src/main/java/com/mapcode/UnknownTerritoryException.java index 22d02ba..d2d38b8 100644 --- a/src/main/java/com/mapcode/UnknownTerritoryException.java +++ b/src/main/java/com/mapcode/UnknownTerritoryException.java @@ -1,11 +1,11 @@ /* - * Copyright (C) 2014-2017, Stichting Mapcode Foundation (http://www.mapcode.com) + * Copyright (C) 2016-2021, Stichting Mapcode Foundation (http://www.mapcode.com) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, diff --git a/src/main/resources/com/mapcode/README.md b/src/main/resources/com/mapcode/README.md index e00fac4..d358e5f 100644 --- a/src/main/resources/com/mapcode/README.md +++ b/src/main/resources/com/mapcode/README.md @@ -1,7 +1,7 @@ The binary file "mminfo.dat" is subject to the following copyright and license statements: -Copyright (C) 2014-2017, Stichting Mapcode Foundation (http://www.mapcode.com) +Copyright (C) 2014-2019, Stichting Mapcode Foundation (http://www.mapcode.com) Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/src/test/java/com/mapcode/AlphabetTest.java b/src/test/java/com/mapcode/AlphabetTest.java index 65e7eb4..47b4c98 100644 --- a/src/test/java/com/mapcode/AlphabetTest.java +++ b/src/test/java/com/mapcode/AlphabetTest.java @@ -1,11 +1,11 @@ /* - * Copyright (C) 2014-2017, Stichting Mapcode Foundation (http://www.mapcode.com) + * Copyright (C) 2016-2021, Stichting Mapcode Foundation (http://www.mapcode.com) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, @@ -103,9 +103,7 @@ public void testConvertToAlphabet() throws Exception { final String codeGreek = Mapcode.convertStringToAlphabet(code, Alphabet.GREEK); LOG.debug("testConvertToAlphabet: code={}, codeGreek={}", code, codeGreek); final String expect = CODE_TEST_PAIRS[i + 1]; - if (!expect.isEmpty()) { - assertEquals(codeGreek, expect); - } + assertEquals(codeGreek, expect); final String codeAscii = Mapcode.convertStringToPlainAscii(codeGreek); LOG.debug("testConvertToAlphabet: code={}, codeGreek={}, codeAscii={}", code, codeGreek, codeAscii); assertEquals(code, codeAscii); diff --git a/src/test/java/com/mapcode/CheckArgsTest.java b/src/test/java/com/mapcode/CheckArgsTest.java index 8d105be..eb42f78 100644 --- a/src/test/java/com/mapcode/CheckArgsTest.java +++ b/src/test/java/com/mapcode/CheckArgsTest.java @@ -1,11 +1,11 @@ /* - * Copyright (C) 2014-2017, Stichting Mapcode Foundation (http://www.mapcode.com) + * Copyright (C) 2016-2021, Stichting Mapcode Foundation (http://www.mapcode.com) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, diff --git a/src/test/java/com/mapcode/DataModelTest.java b/src/test/java/com/mapcode/DataModelTest.java index 16d37e2..358e166 100644 --- a/src/test/java/com/mapcode/DataModelTest.java +++ b/src/test/java/com/mapcode/DataModelTest.java @@ -1,11 +1,11 @@ /* - * Copyright (C) 2014-2017, Stichting Mapcode Foundation (http://www.mapcode.com) + * Copyright (C) 2016-2021, Stichting Mapcode Foundation (http://www.mapcode.com) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, diff --git a/src/test/java/com/mapcode/DecoderTest.java b/src/test/java/com/mapcode/DecoderTest.java index 06e002b..213ad00 100644 --- a/src/test/java/com/mapcode/DecoderTest.java +++ b/src/test/java/com/mapcode/DecoderTest.java @@ -1,11 +1,11 @@ /* - * Copyright (C) 2014-2017, Stichting Mapcode Foundation (http://www.mapcode.com) + * Copyright (C) 2016-2021, Stichting Mapcode Foundation (http://www.mapcode.com) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, @@ -16,6 +16,7 @@ package com.mapcode; +import com.mapcode.Decoder.Unicode2Ascii; import org.junit.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -26,9 +27,36 @@ public class DecoderTest { private static final Logger LOG = LoggerFactory.getLogger(DecoderTest.class); + @Test + public void tableDecodeChars() { + LOG.info("tableDecodeChars"); + assertEquals("Length: " + Decoder.DECODE_CHARS.length, 256, Decoder.DECODE_CHARS.length); + } + + @Test + public void tableAscii2Language() { + LOG.info("tableAscii2Language"); + assertEquals(Decoder.ASCII2LANGUAGE.length, Decoder.UNICODE2ASCII.length - 10 /* Digits */ - 3 /* Lowercase */); + int i = 1; + for (final char[] chars : Decoder.ASCII2LANGUAGE) { + assertEquals("At row " + i + ", length: " + chars.length, 36, chars.length); + ++i; + } + } + + @Test + public void tableUnicodeToAscii() { + LOG.info("tableUnicodeToAscii"); + for (final Unicode2Ascii unicode2Ascii : Decoder.UNICODE2ASCII) { + assertEquals("Error at: u" + Integer.toHexString(unicode2Ascii.min), + (int) unicode2Ascii.max - (int) unicode2Ascii.min, unicode2Ascii.convert.length() - 1); + } + } + @SuppressWarnings("JUnitTestMethodWithNoAssertions") @Test public void getInternationalGrid() { + LOG.info("getInternationalGrid"); final DataModel dataModel = DataModel.getInstance(); final int world = Territory.AAA.getNumber(); final int to = dataModel.getDataLastRecord(world); diff --git a/src/test/java/com/mapcode/EncodeDecodeTest.java b/src/test/java/com/mapcode/EncodeDecodeTest.java index c1ed663..a0e4f1a 100644 --- a/src/test/java/com/mapcode/EncodeDecodeTest.java +++ b/src/test/java/com/mapcode/EncodeDecodeTest.java @@ -1,11 +1,11 @@ /* - * Copyright (C) 2014-2017, Stichting Mapcode Foundation (http://www.mapcode.com) + * Copyright (C) 2016-2021, Stichting Mapcode Foundation (http://www.mapcode.com) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, diff --git a/src/test/java/com/mapcode/EncoderTest.java b/src/test/java/com/mapcode/EncoderTest.java index 696f1cd..e1ac239 100644 --- a/src/test/java/com/mapcode/EncoderTest.java +++ b/src/test/java/com/mapcode/EncoderTest.java @@ -1,11 +1,11 @@ /* - * Copyright (C) 2014-2017, Stichting Mapcode Foundation (http://www.mapcode.com) + * Copyright (C) 2016-2021, Stichting Mapcode Foundation (http://www.mapcode.com) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, diff --git a/src/test/java/com/mapcode/MapcodeTest.java b/src/test/java/com/mapcode/MapcodeTest.java index 76a1582..c8b0db2 100644 --- a/src/test/java/com/mapcode/MapcodeTest.java +++ b/src/test/java/com/mapcode/MapcodeTest.java @@ -1,11 +1,11 @@ /* - * Copyright (C) 2014-2017, Stichting Mapcode Foundation (http://www.mapcode.com) + * Copyright (C) 2016-2021, Stichting Mapcode Foundation (http://www.mapcode.com) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, @@ -28,6 +28,9 @@ public class MapcodeTest { @Test public void checkValidMapcodeFormat() { LOG.info("checkValidMapcodeFormat"); + assertTrue(Mapcode.isValidMapcodeFormat(" A1.B1")); + assertTrue(Mapcode.isValidMapcodeFormat("A1.B1 ")); + assertTrue(Mapcode.isValidMapcodeFormat(" A1.B1 ")); assertTrue(Mapcode.isValidMapcodeFormat("A1.B1")); assertTrue(Mapcode.isValidMapcodeFormat("a1.B1")); assertTrue(Mapcode.isValidMapcodeFormat("00.01")); @@ -44,6 +47,13 @@ public void checkValidMapcodeFormat() { assertTrue(Mapcode.isValidMapcodeFormat("AA.AA-1Y")); } + @Test + public void checkValidMapcodeFormatUnicode() { + LOG.info("checkValidMapcodeFormatUnicode"); + assertTrue(Mapcode.isValidMapcodeFormat("THA จก.ผถฉ๕")); // THA GB.RMH5 + assertTrue(Mapcode.isValidMapcodeFormat("รฉะ จก.ผถฉ๕")); // THA GB.RMH5 + } + @Test public void checkValidPrecisionFormats() { LOG.info("checkValidPrecisionFormats"); @@ -83,6 +93,8 @@ public void checkInvalidPrecisionFormats() { LOG.info("checkInvalidPrecisionFormats"); // Territory code must be correct syntax. + assertFalse(Mapcode.isValidMapcodeFormat(null)); + assertFalse(Mapcode.isValidMapcodeFormat("")); assertFalse(Mapcode.isValidMapcodeFormat("NL- XX.XX")); assertFalse(Mapcode.isValidMapcodeFormat("US IN XX.XX")); diff --git a/src/test/java/com/mapcode/PointTest.java b/src/test/java/com/mapcode/PointTest.java index b5e1ef5..1ca5d6c 100644 --- a/src/test/java/com/mapcode/PointTest.java +++ b/src/test/java/com/mapcode/PointTest.java @@ -1,11 +1,11 @@ /* - * Copyright (C) 2014-2017, Stichting Mapcode Foundation (http://www.mapcode.com) + * Copyright (C) 2016-2021, Stichting Mapcode Foundation (http://www.mapcode.com) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, diff --git a/src/test/java/com/mapcode/ReferenceFileTest.java b/src/test/java/com/mapcode/ReferenceFileTest.java index 0596b2f..0d9a8dc 100644 --- a/src/test/java/com/mapcode/ReferenceFileTest.java +++ b/src/test/java/com/mapcode/ReferenceFileTest.java @@ -1,11 +1,11 @@ /* - * Copyright (C) 2014-2017, Stichting Mapcode Foundation (http://www.mapcode.com) + * Copyright (C) 2016-2021, Stichting Mapcode Foundation (http://www.mapcode.com) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, diff --git a/src/test/java/com/mapcode/TerritoryTest.java b/src/test/java/com/mapcode/TerritoryTest.java index 74bd878..b0c23fc 100644 --- a/src/test/java/com/mapcode/TerritoryTest.java +++ b/src/test/java/com/mapcode/TerritoryTest.java @@ -1,11 +1,11 @@ /* - * Copyright (C) 2014-2017, Stichting Mapcode Foundation (http://www.mapcode.com) + * Copyright (C) 2016-2021, Stichting Mapcode Foundation (http://www.mapcode.com) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, @@ -36,6 +36,14 @@ public void emptyTerritoryNumberTest() { Territory.fromString(""); } + @Test + public void checkConvert() { + LOG.info("checkConvert"); + final String s1 = "รฉะ ฑง.ดฯง"; + final String s2 = Mapcode.convertStringToPlainAscii(s1); + assertEquals("THA KF.LZF", s2); + } + @Test public void checkFullName() { LOG.info("checkFullName"); @@ -299,7 +307,7 @@ public void testGetCountryISO2Codes() { LOG.info("testGetCountryISO2Codes"); final Set countryISO2Codes = Territory.allCountryISO2Codes(); LOG.info("set={}", countryISO2Codes); - assertEquals(251, countryISO2Codes.size()); + assertEquals(250, countryISO2Codes.size()); assertEquals(2, countryISO2Codes.iterator().next().length()); } @@ -308,7 +316,7 @@ public void testGetCountryISO3Codes() { LOG.info("testGetCountryISO3Codes"); final Set countryISO3Codes = Territory.allCountryISO3Codes(); LOG.info("set={}", countryISO3Codes); - assertEquals(251, countryISO3Codes.size()); + assertEquals(250, countryISO3Codes.size()); assertEquals(3, countryISO3Codes.iterator().next().length()); } } diff --git a/src/test/resources/log4j.xml b/src/test/resources/log4j.xml index f6b3cf3..26da1c8 100644 --- a/src/test/resources/log4j.xml +++ b/src/test/resources/log4j.xml @@ -1,19 +1,19 @@ + ~ Copyright (C) 2016-2021, Stichting Mapcode Foundation (http://www.mapcode.com) + ~ + ~ Licensed under the Apache License, Version 2.0 (the "License"); + ~ you may not use this file except in compliance with the License. + ~ You may obtain a copy of the License at + ~ + ~ http://www.apache.org/licenses/LICENSE-2.0 + ~ + ~ Unless required by applicable law or agreed to in writing, software + ~ distributed under the License is distributed on an "AS IS" BASIS, + ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + ~ See the License for the specific language governing permissions and + ~ limitations under the License. + --> diff --git a/src/test/resources/show3d/show3d.pde b/src/test/resources/show3d/show3d.pde index f6a2ec8..414108d 100644 --- a/src/test/resources/show3d/show3d.pde +++ b/src/test/resources/show3d/show3d.pde @@ -1,5 +1,5 @@ /* - * Copyright (C) 2014-2017, Stichting Mapcode Foundation (http://www.mapcode.com) + * Copyright (C) 2014-2019, Stichting Mapcode Foundation (http://www.mapcode.com) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/test/resources/show3d/sketch.properties b/src/test/resources/show3d/sketch.properties index 8630fa2..bf88b4f 100644 --- a/src/test/resources/show3d/sketch.properties +++ b/src/test/resources/show3d/sketch.properties @@ -1,2 +1,18 @@ +# +# Copyright (C) 2016-2021, Stichting Mapcode Foundation (http://www.mapcode.com) +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + mode.id=processing.mode.java.JavaMode mode=Java