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/05/15 17:41:25 UTC
svn commit: r1743924 -
/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/CoordinateOperationRegistry.java
Author: desruisseaux
Date: Sun May 15 17:41:25 2016
New Revision: 1743924
URL: http://svn.apache.org/viewvc?rev=1743924&view=rev
Log:
Bug fix: need to check accuracy and domain of validity before to compute the inverse of an operation.
Modified:
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/CoordinateOperationRegistry.java
Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/CoordinateOperationRegistry.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/CoordinateOperationRegistry.java?rev=1743924&r1=1743923&r2=1743924&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/CoordinateOperationRegistry.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/CoordinateOperationRegistry.java [UTF-8] Sun May 15 17:41:25 2016
@@ -423,22 +423,14 @@ class CoordinateOperationRegistry {
for (final Iterator<CoordinateOperation> it=operations.iterator(); it.hasNext();) {
CoordinateOperation candidate;
try {
- try {
- candidate = it.next();
- } catch (BackingStoreException exception) {
- throw exception.unwrapOrRethrow(FactoryException.class);
- }
- if (inverse) try {
- candidate = inverse(candidate);
- } catch (NoninvertibleTransformException exception) {
- // It may be a normal failure - the operation is not required to be invertible.
- Logging.recoverableException(Logging.getLogger(Loggers.COORDINATE_OPERATION),
- CoordinateOperationRegistry.class, "createOperation", exception);
+ candidate = it.next();
+ } catch (BackingStoreException exception) {
+ FactoryException cause = exception.unwrapOrRethrow(FactoryException.class);
+ if (cause instanceof MissingFactoryResourceException) {
+ log(cause);
continue;
}
- } catch (MissingFactoryResourceException e) {
- log(e);
- continue;
+ throw cause;
}
if (candidate != null) {
/*
@@ -456,6 +448,22 @@ class CoordinateOperationRegistry {
final double accuracy = CRS.getLinearAccuracy(candidate);
if (bestChoice == null || area != largestArea || accuracy < finestAccuracy) {
/*
+ * Inverse the operation only after we verified the metadata (domain of validity,
+ * accuracy, etc.) since the creation of inverse operation is not guaranteed to
+ * preserve all metadata.
+ */
+ if (inverse) try {
+ candidate = inverse(candidate);
+ } catch (NoninvertibleTransformException exception) {
+ // It may be a normal failure - the operation is not required to be invertible.
+ Logging.recoverableException(Logging.getLogger(Loggers.COORDINATE_OPERATION),
+ CoordinateOperationRegistry.class, "createOperation", exception);
+ continue;
+ } catch (MissingFactoryResourceException e) {
+ log(e);
+ continue;
+ }
+ /*
* It is possible that the CRS given to this method were not quite right. For example the user
* may have created his CRS from a WKT using a different axis order than the order specified by
* the authority and still (wrongly) call those CRS "EPSG:xxxx". So we check if the source and