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/04/06 16:07:10 UTC

svn commit: r1737981 - in /sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation: AbstractCoordinateOperation.java DefaultPassThroughOperation.java

Author: desruisseaux
Date: Wed Apr  6 14:07:09 2016
New Revision: 1737981

URL: http://svn.apache.org/viewvc?rev=1737981&view=rev
Log:
Add pseuso-WKT formatting for PassThroughOperation.

Modified:
    sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/AbstractCoordinateOperation.java
    sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/DefaultPassThroughOperation.java

Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/AbstractCoordinateOperation.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/AbstractCoordinateOperation.java?rev=1737981&r1=1737980&r2=1737981&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/AbstractCoordinateOperation.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/AbstractCoordinateOperation.java [UTF-8] Wed Apr  6 14:07:09 2016
@@ -36,6 +36,7 @@ import org.opengis.referencing.operation
 import org.opengis.referencing.operation.CoordinateOperation;
 import org.opengis.referencing.operation.OperationMethod;
 import org.opengis.referencing.operation.MathTransform;
+import org.opengis.referencing.operation.PassThroughOperation;
 import org.opengis.parameter.GeneralParameterValue;
 import org.opengis.parameter.ParameterDescriptorGroup;
 import org.opengis.parameter.ParameterValueGroup;
@@ -867,12 +868,16 @@ check:      for (int isTarget=0; ; isTar
          * This decision is SIS-specific since the WKT 2 specification does not define concatenated operations.
          * This choice may change in any future SIS version.
          */
-        final boolean isComponent = (formatter.getEnclosingElement(1) instanceof ConcatenatedOperation);
-        if (!isComponent) {
-            append(formatter, getSourceCRS(), WKTKeywords.SourceCRS);
-        }
-        if (!(this instanceof ConcatenatedOperation)) {
-            append(formatter, getTargetCRS(), WKTKeywords.TargetCRS);
+        final FormattableObject enclosing = formatter.getEnclosingElement(1);
+        final boolean isSubOperation = (enclosing instanceof PassThroughOperation);
+        final boolean isComponent    = (enclosing instanceof ConcatenatedOperation);
+        if (!isSubOperation) {
+            if (!isComponent) {
+                append(formatter, getSourceCRS(), WKTKeywords.SourceCRS);
+            }
+            if (!(this instanceof ConcatenatedOperation)) {
+                append(formatter, getTargetCRS(), WKTKeywords.TargetCRS);
+            }
         }
         final OperationMethod method = getMethod();
         if (method != null) {
@@ -894,7 +899,7 @@ check:      for (int isTarget=0; ; isTar
                 formatter.indent(-1);
             }
         }
-        if (!isComponent) {
+        if (!isSubOperation && !isComponent) {
             append(formatter, getInterpolationCRS(), WKTKeywords.InterpolationCRS);
             final double accuracy = getLinearAccuracy();
             if (accuracy > 0) {

Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/DefaultPassThroughOperation.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/DefaultPassThroughOperation.java?rev=1737981&r1=1737980&r2=1737981&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/DefaultPassThroughOperation.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/DefaultPassThroughOperation.java [UTF-8] Wed Apr  6 14:07:09 2016
@@ -33,6 +33,8 @@ import org.apache.sis.util.UnsupportedIm
 import org.apache.sis.util.ArgumentChecks;
 import org.apache.sis.util.ComparisonMode;
 import org.apache.sis.util.resources.Errors;
+import org.apache.sis.io.wkt.FormattableObject;
+import org.apache.sis.io.wkt.Formatter;
 
 import static org.apache.sis.util.Utilities.deepEquals;
 
@@ -249,6 +251,33 @@ public class DefaultPassThroughOperation
         return super.computeHashCode() + 31 * operation.hashCode();
     }
 
+    /**
+     * Formats this coordinate operation in a pseudo-Well Known Text (WKT) format.
+     * Current format is specific to Apache SIS and may change in any future version
+     * if a standard format for pass through operations is defined.
+     *
+     * @param  formatter The formatter to use.
+     * @return Currently {@code "PassThroughOperation"} (may change in any future version).
+     *
+     * @since 0.7
+     */
+    @Override
+    protected String formatTo(final Formatter formatter) {
+        super.formatTo(formatter);
+        formatter.append(new FormattableObject() {
+            @Override protected String formatTo(final Formatter formatter) {
+                for (final int i : getModifiedCoordinates()) {
+                    formatter.append(i);
+                }
+                return "ModifiedCoordinates";
+            }
+        });
+        formatter.newLine();
+        formatter.append(castOrCopy(getOperation()));
+        formatter.setInvalidWKT(this, null);
+        return "PassThroughOperation";
+    }
+