You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sis.apache.org by de...@apache.org on 2016/02/22 14:39:45 UTC
svn commit: r1731641 - in /sis/branches/JDK8/core/sis-referencing/src:
main/java/org/apache/sis/referencing/EPSGFactoryFallback.java
test/java/org/apache/sis/referencing/EPSGFactoryFallbackTest.java
Author: desruisseaux
Date: Mon Feb 22 13:39:45 2016
New Revision: 1731641
URL: http://svn.apache.org/viewvc?rev=1731641&view=rev
Log:
EPSG fallback shall ignore the prefix in codes like "EPSG:4326".
Modified:
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/EPSGFactoryFallback.java
sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/EPSGFactoryFallbackTest.java
Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/EPSGFactoryFallback.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/EPSGFactoryFallback.java?rev=1731641&r1=1731640&r2=1731641&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/EPSGFactoryFallback.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/EPSGFactoryFallback.java [UTF-8] Mon Feb 22 13:39:45 2016
@@ -35,7 +35,9 @@ import org.apache.sis.referencing.factor
import org.apache.sis.internal.referencing.provider.TransverseMercator;
import org.apache.sis.internal.util.Constants;
import org.apache.sis.util.iso.SimpleInternationalString;
+import org.apache.sis.util.iso.DefaultNameSpace;
import org.apache.sis.util.resources.Errors;
+import org.apache.sis.util.CharSequences;
import org.apache.sis.util.Debug;
@@ -150,7 +152,16 @@ final class EPSGFactoryFallback extends
public IdentifiedObject createObject(final String code) throws NoSuchAuthorityCodeException {
NumberFormatException cause = null;
try {
- final int n = Integer.parseInt(code);
+ /*
+ * Parse the value after the last ':'. We do not bother to verify if the part before ':' is legal
+ * (e.g. "EPSG:4326", "EPSG::4326", "urn:ogc:def:crs:epsg::4326", etc.) because this analysis has
+ * already be done by MultiAuthoritiesFactory. We nevertheless skip the prefix in case this factory
+ * is used directly (not through MultiAuthoritiesFactory), which should be rare. The main case is
+ * when using the factory returned by AuthorityFactories.fallback(…).
+ */
+ final int n = Integer.parseInt(CharSequences.trimWhitespaces(code,
+ code.lastIndexOf(DefaultNameSpace.DEFAULT_SEPARATOR) + 1,
+ code.length()).toString());
for (final CommonCRS crs : CommonCRS.values()) {
if (n == crs.geographic) return crs.geographic();
if (n == crs.geocentric) return crs.geocentric();
Modified: sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/EPSGFactoryFallbackTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/EPSGFactoryFallbackTest.java?rev=1731641&r1=1731640&r2=1731641&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/EPSGFactoryFallbackTest.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/EPSGFactoryFallbackTest.java [UTF-8] Mon Feb 22 13:39:45 2016
@@ -87,6 +87,8 @@ public final strictfp class EPSGFactoryF
verifyCreate(CommonCRS.WGS84 .geocentric(), "4978");
verifyCreate(CommonCRS.WGS72 .geocentric(), "4984");
verifyCreate(CommonCRS.ETRS89.geocentric(), "4936");
+ verifyCreate(CommonCRS.WGS84 .geographic(), "EPSG:4326");
+ verifyCreate(CommonCRS.WGS72 .geographic(), "EPSG::4322");
verifyCreate(CommonCRS.WGS84 .geographic3D(), "4979");
verifyCreate(CommonCRS.WGS72 .geographic3D(), "4985");
verifyCreate(CommonCRS.ETRS89.geographic3D(), "4937");