Author: desruisseaux
Date: Mon Mar 16 12:27:50 2015
New Revision: 1666978

URL: http://svn.apache.org/r1666978
Log:
Added javadoc and a test case for "Longitude rotation" operation method.

Added:
    
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/package-info.java
   (with props)
    
sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/provider/LongitudeRotationTest.java
   (with props)
Modified:
    
sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/Formatter.java
    
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/j2d/AffineTransform2D.java
    
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/LongitudeRotation.java
    
sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/test/suite/ReferencingTestSuite.java

Modified: 
sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/Formatter.java
URL: 
http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/Formatter.java?rev=1666978&r1=1666977&r2=1666978&view=diff
==============================================================================
--- 
sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/Formatter.java
 [UTF-8] (original)
+++ 
sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/Formatter.java
 [UTF-8] Mon Mar 16 12:27:50 2015
@@ -91,7 +91,7 @@ import org.apache.sis.metadata.iso.exten
  *
  * @author  Martin Desruisseaux (IRD, Geomatys)
  * @since   0.4
- * @version 0.5
+ * @version 0.6
  * @module
  */
 public class Formatter implements Localized {
@@ -1243,12 +1243,15 @@ public class Formatter implements Locali
             append((FormattableObject) value);
         } else if (value instanceof IdentifiedObject) {
             
append(ReferencingServices.getInstance().toFormattableObject((IdentifiedObject) 
value));
-        }
-        else if (value instanceof MathTransform)         
append((MathTransform)         value);
-        else if (value instanceof Matrix)                append((Matrix)       
         value);
-        else if (value instanceof Unit<?>)               append((Unit<?>)      
         value);
-        else if (value instanceof GeographicBoundingBox) 
append((GeographicBoundingBox) value, BBOX_ACCURACY);
-        else if (value instanceof VerticalExtent) {
+        } else if (value instanceof MathTransform) {
+            append((MathTransform) value);
+        } else if (value instanceof Matrix) {
+            append((Matrix) value);
+        } else if (value instanceof Unit<?>) {
+            append((Unit<?>) value);
+        } else if (value instanceof GeographicBoundingBox) {
+            append((GeographicBoundingBox) value, BBOX_ACCURACY);
+        } else if (value instanceof VerticalExtent) {
             appendVerticalExtent(Extents.getVerticalRange(new 
SimpleExtent(null, (VerticalExtent) value, null)));
         } else if (value instanceof TemporalExtent) {
             appendTemporalExtent(Extents.getTimeRange(new SimpleExtent(null, 
null, (TemporalExtent) value)));

Modified: 
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/j2d/AffineTransform2D.java
URL: 
http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/j2d/AffineTransform2D.java?rev=1666978&r1=1666977&r2=1666978&view=diff
==============================================================================
--- 
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/j2d/AffineTransform2D.java
 [UTF-8] (original)
+++ 
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/j2d/AffineTransform2D.java
 [UTF-8] Mon Mar 16 12:27:50 2015
@@ -122,6 +122,7 @@ public class AffineTransform2D extends I
               pz(elements[1]), pz(elements[4]),
               pz(elements[2]), pz(elements[5]));
         matrix = new AffineMatrix(this, elements);
+        // Do not call freeze(), as it was implied by above line.
     }
 
     /**

Modified: 
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/LongitudeRotation.java
URL: 
http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/LongitudeRotation.java?rev=1666978&r1=1666977&r2=1666978&view=diff
==============================================================================
--- 
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/LongitudeRotation.java
 [UTF-8] (original)
+++ 
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/LongitudeRotation.java
 [UTF-8] Mon Mar 16 12:27:50 2015
@@ -30,6 +30,9 @@ import org.apache.sis.parameter.Paramete
 
 /**
  * The provider for "<cite>Longitude rotation</cite>" (EPSG:9601).
+ * The "Longitude rotation" is created as an affine transform containing only 
a translation term in degrees.
+ * Advantage of using an affine transform for such simple operation is that 
this {@code AffineTransform} can
+ * be efficiently concatenated with other affine transform instances.
  *
  * <blockquote><p><b>Operation name:</b> {@code Longitude rotation}</p>
  * <table class="sis">
@@ -38,6 +41,9 @@ import org.apache.sis.parameter.Paramete
  *   <tr><td>{@code Longitude offset}</td> <td></td></tr>
  * </table></blockquote>
  *
+ * The Apache SIS implementation of this operation method always perform the 
longitude rotation in degrees.
+ * The longitude axis of source and target CRS shall be converted to degrees 
before this operation is applied.
+ *
  * @author  Martin Desruisseaux (IRD, Geomatys)
  * @since   0.6
  * @version 0.6
@@ -50,6 +56,11 @@ public final class LongitudeRotation ext
     private static final long serialVersionUID = -2104496465933824935L;
 
     /**
+     * The name of the {@link #OFFSET} parameter.
+     */
+    static final String NAME = "Longitude offset";
+
+    /**
      * The operation parameter descriptor for the "<cite>longitude 
offset</cite>" parameter value.
      */
     private static final ParameterDescriptor<Double> OFFSET;
@@ -60,7 +71,7 @@ public final class LongitudeRotation ext
     static final ParameterDescriptorGroup PARAMETERS;
     static {
         final ParameterBuilder builder = builder();
-        OFFSET = builder.addName("Longitude offset").createBounded(-180, +180, 
Double.NaN, NonSI.DEGREE_ANGLE);
+        OFFSET     = 
builder.addIdentifier("8602").addName(NAME).createBounded(-180, +180, 
Double.NaN, NonSI.DEGREE_ANGLE);
         PARAMETERS = builder.addIdentifier("9601").addName("Longitude 
rotation").createGroup(OFFSET);
     }
 
@@ -83,6 +94,11 @@ public final class LongitudeRotation ext
 
     /**
      * Creates a transform from the specified group of parameter values.
+     * The parameter value is unconditionally converted to degrees.
+     *
+     * <p>The operation is created as an affine transform. We do not override 
the
+     * {@link AffineTransform2D#getParameterDescriptors()} and {@link 
AffineTransform2D#getParameterValues()} methods
+     * in order to make that fact clearer.</p>
      *
      * @param  values The group of parameter values.
      * @return The created math transform.
@@ -91,46 +107,6 @@ public final class LongitudeRotation ext
     @Override
     public MathTransform createMathTransform(final ParameterValueGroup values) 
throws ParameterNotFoundException {
         final double offset = 
Parameters.castOrWrap(values).doubleValue(OFFSET);
-        return new Transform(offset);
-    }
-
-    /**
-     * The "Longitude rotation" transform, as an affine transform containing 
only a translation term.
-     * Advantage of using an affine transform for such simple operation is 
that this {@code AffineTransform}
-     * can be efficiently concatenated with other affine transform instances.
-     */
-    private static final class Transform extends AffineTransform2D {
-        /**
-         * For cross-version compatibility.
-         */
-        private static final long serialVersionUID = 1267160949067495041L;
-
-        /**
-         * Creates a new longitude rotation for the given offset.
-         */
-        Transform(final double offset) {
-            super(1, 0, 0, 1, offset, 0);
-        }
-
-        /**
-         * Returns the parameter descriptors for this math transform.
-         */
-        @Override
-        public ParameterDescriptorGroup getParameterDescriptors() {
-            return PARAMETERS;
-        }
-
-        /**
-         * Returns the matrix elements as a group of parameters values. The 
number of parameters
-         * depends on the matrix size. Only matrix elements different from 
their default value
-         * will be included in this group.
-         */
-        @Override
-        public ParameterValueGroup getParameterValues() {
-            assert (getType() & ~TYPE_TRANSLATION) == 0;  // This transform 
shall perform only a translation.
-            final ParameterValueGroup p = PARAMETERS.createValue();
-            p.parameter("Longitude offset").setValue(getTranslateX());
-            return p;
-        }
+        return new AffineTransform2D(1, 0, 0, 1, offset, 0);
     }
 }

Added: 
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/package-info.java
URL: 
http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/package-info.java?rev=1666978&view=auto
==============================================================================
--- 
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/package-info.java
 (added)
+++ 
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/package-info.java
 [UTF-8] Mon Mar 16 12:27:50 2015
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ */
+
+/**
+ * Relationship between any two {@linkplain 
org.apache.sis.referencing.crs.AbstractCRS Coordinate Reference Systems}.
+ * An explanation for this package is provided in the {@linkplain 
org.opengis.referencing.operation OpenGIS® javadoc}.
+ * The remaining discussion on this page is specific to the Apache SIS 
implementation.
+ *
+ * <p>This package provides an ISO 19111 {@linkplain 
org.apache.sis.referencing.operation.AbstractCoordinateOperation
+ * Coordinate Operation implementation} and support classes. The actual 
transform work is performed by the following
+ * sub-packages, but most users will not need to deal with them directly:</p>
+ *
+ * <ul>
+ *   <li>{@link org.apache.sis.referencing.operation.projection} for map 
projections</li>
+ *   <li>{@link org.apache.sis.referencing.operation.transform} for any 
transform other than map projections</li>
+ * </ul>
+ *
+ * {@section Apache SIS specific behavior}
+ * The following operations have a behavior in Apache SIS which may be 
different
+ * than the behavior found in other softwares. Those particularities apply 
only when the math transform is
+ * {@linkplain 
org.apache.sis.referencing.operation.transform.DefaultMathTransformFactory#createParameterizedTransform
+ * created directly}. Users do not need to care about them when the coordinate 
operation is
+ * {@link 
org.apache.sis.referencing.operation.DefaultCoordinateOperationFactory#createOperation
+ * inferred by Apache SIS for a given pair of CRS}.
+ *
+ * <ul>
+ *   <li><b>Longitude rotation</b> (EPSG:9601) — the longitude offset may be 
specified in any units,
+ *     but SIS unconditionally converts the value to degrees. Consequently the 
user is responsible
+ *     for converting the longitude axis of source and target CRS to degrees 
before this operation is applied.</li>
+ * </ul>
+ *
+ * @author  Martin Desruisseaux (IRD, Geomatys)
+ * @version 0.6
+ * @since   0.6
+ * @module
+ */
+package org.apache.sis.referencing.operation;

Propchange: 
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/package-info.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/package-info.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain;charset=UTF-8

Added: 
sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/provider/LongitudeRotationTest.java
URL: 
http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/provider/LongitudeRotationTest.java?rev=1666978&view=auto
==============================================================================
--- 
sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/provider/LongitudeRotationTest.java
 (added)
+++ 
sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/provider/LongitudeRotationTest.java
 [UTF-8] Mon Mar 16 12:27:50 2015
@@ -0,0 +1,79 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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 org.apache.sis.internal.referencing.provider;
+
+import javax.measure.unit.NonSI;
+import org.opengis.parameter.ParameterValueGroup;
+import org.opengis.referencing.operation.MathTransform;
+import org.apache.sis.referencing.operation.transform.LinearTransform;
+import org.apache.sis.referencing.operation.matrix.Matrix3;
+import org.apache.sis.test.DependsOnMethod;
+import org.apache.sis.test.DependsOn;
+import org.apache.sis.test.TestCase;
+import org.junit.Test;
+
+import static org.apache.sis.test.MetadataAssert.*;
+
+
+/**
+ * Tests the {@link LongitudeRotation} class.
+ *
+ * @author  Martin Desruisseaux (Geomatys)
+ * @since   0.6
+ * @version 0.6
+ * @module
+ */
+@DependsOn(AffineTest.class)
+public final strictfp class LongitudeRotationTest extends TestCase {
+    /**
+     * Tests {@link 
LongitudeRotation#createMathTransform(ParameterValueGroup)}.
+     */
+    @Test
+    public void testCreateMathTransform() {
+        final LongitudeRotation provider = new LongitudeRotation();
+        ParameterValueGroup p = provider.getParameters().createValue();
+        p.parameter(LongitudeRotation.NAME).setValue(2.5969213, NonSI.GRADE);  
 // Paris meridian
+        final MathTransform mt = provider.createMathTransform(p);
+        /*
+         * Verify the full matrix. Note that the longitude offset is expected 
to be in degrees.
+         * This conversion from grad to degrees is specific to Apache SIS and 
may be revised in
+         * future version. See org.apache.sis.referencing.operation package 
javadoc.
+         */
+        assertInstanceOf("Shall be an affine transform.", 
LinearTransform.class, mt);
+        assertMatrixEquals("Expected a longitude rotation",
+                new Matrix3(1, 0, 2.33722917,
+                            0, 1, 0,
+                            0, 0, 1), ((LinearTransform) mt).getMatrix(), 
1E-16);
+    }
+
+    /**
+     * Tests WKT formatting. Note that we do not expect a {@code 
Param_MT[“Longitude rotation”, …]} text
+     * since we want to make clear that Apache SIS implements longitude 
rotation by an affine transform.
+     */
+    @Test
+    @DependsOnMethod("testCreateMathTransform")
+    public void testWKT() {
+        final LongitudeRotation provider = new LongitudeRotation();
+        final ParameterValueGroup p = provider.getParameters().createValue();
+        p.parameter(LongitudeRotation.NAME).setValue(2.5969213, NonSI.GRADE);
+        assertWktEquals(
+                "Param_MT[“Affine”,\n" +
+                "  Parameter[“num_row”, 3],\n" +
+                "  Parameter[“num_col”, 3],\n" +
+                "  Parameter[“elt_0_2”, 2.33722917]]", 
provider.createMathTransform(p));
+    }
+}

Propchange: 
sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/provider/LongitudeRotationTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/provider/LongitudeRotationTest.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain;charset=UTF-8

Modified: 
sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/test/suite/ReferencingTestSuite.java
URL: 
http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/test/suite/ReferencingTestSuite.java?rev=1666978&r1=1666977&r2=1666978&view=diff
==============================================================================
--- 
sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/test/suite/ReferencingTestSuite.java
 [UTF-8] (original)
+++ 
sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/test/suite/ReferencingTestSuite.java
 [UTF-8] Mon Mar 16 12:27:50 2015
@@ -83,6 +83,7 @@ import org.junit.BeforeClass;
     org.apache.sis.referencing.operation.DefaultFormulaTest.class,
     org.apache.sis.referencing.operation.DefaultOperationMethodTest.class,
     org.apache.sis.internal.referencing.provider.AffineTest.class,
+    org.apache.sis.internal.referencing.provider.LongitudeRotationTest.class,
     org.apache.sis.internal.referencing.provider.AllProvidersTest.class,
     
org.apache.sis.referencing.operation.transform.OperationMethodSetTest.class,
     
org.apache.sis.referencing.operation.transform.DefaultMathTransformFactoryTest.class,


Reply via email to