sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1702267 - in /sis/trunk: ./ core/sis-metadata/src/test/java/org/apache/sis/internal/jaxb/code/ core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/j2d/ core/sis-referencing/src/main/java/org/apache/sis/referencing/ core/...
Date Thu, 10 Sep 2015 14:36:01 GMT
Author: desruisseaux
Date: Thu Sep 10 14:36:00 2015
New Revision: 1702267

URL: http://svn.apache.org/r1702267
Log:
Merge from the JDK6 branch.

Modified:
    sis/trunk/   (props changed)
    sis/trunk/core/sis-metadata/src/test/java/org/apache/sis/internal/jaxb/code/EnumMarshallingTest.java
    sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/j2d/AffineMatrix.java
    sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/j2d/AffineTransform2D.java
    sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/Builder.java
    sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/AbstractDatum.java
    sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/matrix/GeneralMatrix.java
    sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/matrix/Solver.java
    sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/IdentityTransform.java
    sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/io/wkt/GeodeticObjectParserTest.java
    sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/io/wkt/WKTFormatTest.java
    sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/ConcatenatedTransformTest.java

Propchange: sis/trunk/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Thu Sep 10 14:36:00 2015
@@ -1,4 +1,4 @@
 /sis/branches/Android:1430670-1480699
-/sis/branches/JDK6:1394364-1702026
-/sis/branches/JDK7:1394913-1702025
-/sis/branches/JDK8:1584960-1702023
+/sis/branches/JDK6:1394364-1702257
+/sis/branches/JDK7:1394913-1702251
+/sis/branches/JDK8:1584960-1702245

Modified: sis/trunk/core/sis-metadata/src/test/java/org/apache/sis/internal/jaxb/code/EnumMarshallingTest.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-metadata/src/test/java/org/apache/sis/internal/jaxb/code/EnumMarshallingTest.java?rev=1702267&r1=1702266&r2=1702267&view=diff
==============================================================================
--- sis/trunk/core/sis-metadata/src/test/java/org/apache/sis/internal/jaxb/code/EnumMarshallingTest.java
[UTF-8] (original)
+++ sis/trunk/core/sis-metadata/src/test/java/org/apache/sis/internal/jaxb/code/EnumMarshallingTest.java
[UTF-8] Thu Sep 10 14:36:00 2015
@@ -17,6 +17,7 @@
 package org.apache.sis.internal.jaxb.code;
 
 import java.util.Arrays;
+import java.util.Collection;
 import javax.xml.bind.JAXBException;
 import org.opengis.metadata.identification.TopicCategory;
 import org.apache.sis.metadata.iso.identification.DefaultDataIdentification;
@@ -32,22 +33,24 @@ import static org.apache.sis.test.Assert
  *
  * @author  Martin Desruisseaux (Geomatys)
  * @since   0.5
- * @version 0.5
+ * @version 0.6
  * @module
  */
 public final strictfp class EnumMarshallingTest extends XMLTestCase {
     /**
-     * Tests marshaling of a code list which is not in the list of standard codes.
+     * Tests (un)marshaling of an enumeration.
      *
-     * @throws JAXBException If an error occurred while marshaling the XML.
+     * @throws JAXBException If an error occurred while (un)marshaling the XML.
      */
     @Test
-    public void testEnums() throws JAXBException {
-        final DefaultDataIdentification id = new DefaultDataIdentification();
-        id.setTopicCategories(Arrays.asList(
+    public void testTopicCategories() throws JAXBException {
+        final Collection<TopicCategory> expected = Arrays.asList(
                 TopicCategory.OCEANS,
                 TopicCategory.ENVIRONMENT,
-                TopicCategory.HEALTH));
+                TopicCategory.IMAGERY_BASE_MAPS_EARTH_COVER);   // We need to test at least
one enum with many words.
+
+        final DefaultDataIdentification id = new DefaultDataIdentification();
+        id.setTopicCategories(expected);
 
         final String xml = marshal(id);
         assertXmlEquals(
@@ -56,12 +59,17 @@ public final strictfp class EnumMarshall
                 "    <gmd:MD_TopicCategoryCode>environment</gmd:MD_TopicCategoryCode>\n"
+
                 "  </gmd:topicCategory>\n" +
                 "  <gmd:topicCategory>\n" +
-                "    <gmd:MD_TopicCategoryCode>health</gmd:MD_TopicCategoryCode>\n"
+
+                "    <gmd:MD_TopicCategoryCode>imageryBaseMapsEarthCover</gmd:MD_TopicCategoryCode>\n"
+
                 "  </gmd:topicCategory>\n" +
                 "  <gmd:topicCategory>\n" +
                 "    <gmd:MD_TopicCategoryCode>oceans</gmd:MD_TopicCategoryCode>\n"
+
                 "  </gmd:topicCategory>\n" +
                 "</gmd:MD_DataIdentification>",
                 xml, "xmlns:*");
+        /*
+         * Unmarshall the above XML and verify that we find all the topic categories.
+         */
+        final Collection<TopicCategory> unmarshalled = unmarshal(DefaultDataIdentification.class,
xml).getTopicCategories();
+        assertSetEquals(expected, unmarshalled);
     }
 }

Modified: sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/j2d/AffineMatrix.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/j2d/AffineMatrix.java?rev=1702267&r1=1702266&r2=1702267&view=diff
==============================================================================
--- sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/j2d/AffineMatrix.java
[UTF-8] (original)
+++ sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/j2d/AffineMatrix.java
[UTF-8] Thu Sep 10 14:36:00 2015
@@ -175,6 +175,7 @@ final class AffineMatrix implements Exte
      * Returns a copy of the matrix that user can modify.
      */
     @Override
+    @SuppressWarnings("CloneDoesntCallSuperClone")
     public final Matrix clone() {
         return Matrices.copy(this);
     }

Modified: sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/j2d/AffineTransform2D.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/j2d/AffineTransform2D.java?rev=1702267&r1=1702266&r2=1702267&view=diff
==============================================================================
--- sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/j2d/AffineTransform2D.java
[UTF-8] (original)
+++ sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/j2d/AffineTransform2D.java
[UTF-8] Thu Sep 10 14:36:00 2015
@@ -31,6 +31,7 @@ import org.apache.sis.referencing.operat
 import org.apache.sis.referencing.operation.matrix.Matrices;
 import org.apache.sis.referencing.operation.matrix.AffineTransforms2D;
 import org.apache.sis.referencing.operation.transform.LinearTransform;
+import org.apache.sis.internal.referencing.ExtendedPrecisionMatrix;
 import org.apache.sis.internal.referencing.provider.Affine;
 import org.apache.sis.io.wkt.Formatter;
 import org.apache.sis.util.LenientComparable;
@@ -70,9 +71,8 @@ public class AffineTransform2D extends I
      * set to a non-null value before an {@link AffineTransform2D} instance is published.</p>
      *
      * @see #getMatrix()
-     * @see #freeze()
      */
-    private AffineMatrix matrix;
+    private final AffineMatrix matrix;
 
     /**
      * The inverse transform. This field will be computed only when needed.
@@ -80,37 +80,14 @@ public class AffineTransform2D extends I
     private transient volatile AffineTransform2D inverse;
 
     /**
-     * Constructs a <strong>temporarily mutable</strong> identity affine transform.
-     * Callers shall initializing the affine transform to the desired final values,
-     * then invoke {@link #freeze()}.
-     */
-    public AffineTransform2D() {
-        super();
-    }
-
-    /**
-     * Constructs a new affine transform with the same coefficients than the specified transform.
-     *
-     * @param transform The affine transform to copy.
-     * @param mutable {@code true} if this affine transform needs to be <strong>temporarily</strong>
mutable.
-     *        If {@code true}, then caller shall invoke {@link #freeze()} after they completed
initialization.
-     */
-    public AffineTransform2D(final AffineTransform transform, final boolean mutable) {
-        super(transform);
-        if (!mutable) {
-            freeze();
-        }
-    }
-
-    /**
      * Constructs a new affine transform with the same coefficients than the specified transform.
      *
      * @param transform The affine transform to copy.
      */
     public AffineTransform2D(final AffineTransform transform) {
         super(transform);
-        forcePositiveZeros();
-        freeze();
+        forcePositiveZeros();   // Must be invoked before to set the 'matrix' value.
+        matrix = new AffineMatrix(this, null);
     }
 
     /**
@@ -123,7 +100,6 @@ 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.
     }
 
     /**
@@ -141,7 +117,7 @@ public class AffineTransform2D extends I
      */
     public AffineTransform2D(double m00, double m10, double m01, double m11, double m02,
double m12) {
         super(pz(m00), pz(m10), pz(m01), pz(m11), pz(m02), pz(m12));
-        freeze();
+        matrix = new AffineMatrix(this, null);
     }
 
     /**
@@ -167,15 +143,6 @@ public class AffineTransform2D extends I
     }
 
     /**
-     * Makes this {@code AffineTransform2D} immutable.
-     * This method shall be invoked exactly once.
-     */
-    public final void freeze() {
-        assert matrix == null;
-        matrix = new AffineMatrix(this, null);
-    }
-
-    /**
      * Throws an {@link UnsupportedOperationException} when a mutable method
      * is invoked, since {@code AffineTransform2D} must be immutable.
      *
@@ -327,15 +294,25 @@ public class AffineTransform2D extends I
                  * Is okay with the new memory model since Java 5 provided that the field
is
                  * declared volatile (Joshua Bloch, "Effective Java" second edition).
                  */
-                if (inverse == null) try {
-                    final AffineTransform2D work = new AffineTransform2D(this, true);
-                    work.invert();
-                    work.forcePositiveZeros();
-                    work.freeze();
+                if (inverse == null) {
+                    /*
+                     * In a previous version, we were using the Java2D code as below:
+                     *
+                     *     AffineTransform2D work = new AffineTransform2D(this, true);
+                     *     work.invert();
+                     *     work.forcePositiveZeros();
+                     *     work.freeze();
+                     *
+                     * Current version now uses the SIS code instead in order to get the
double-double precision.
+                     * It usually does not make a difference in the result of the matrix
inversion, when ignoring
+                     * the error terms.  But those error terms appear to be significant later,
when the result of
+                     * this matrix inversion is multiplied with other matrices: the double-double
accuracy allows
+                     * us to better detect the terms that are 0 or 1 after matrix concatenation.
+                     */
+                    final AffineTransform2D work = new AffineTransform2D(
+                            ((ExtendedPrecisionMatrix) Matrices.inverse(matrix)).getExtendedElements());
                     work.inverse = this;
                     inverse = work; // Set only on success.
-                } catch (java.awt.geom.NoninvertibleTransformException exception) {
-                    throw new NoninvertibleTransformException(exception.getLocalizedMessage(),
exception);
                 }
             }
         }
@@ -432,6 +409,7 @@ public class AffineTransform2D extends I
      * @return A modifiable copy of this affine transform.
      */
     @Override
+    @SuppressWarnings("CloneDoesntCallSuperClone")
     public AffineTransform clone() {
         return new AffineTransform(this);
     }

Modified: sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/Builder.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/Builder.java?rev=1702267&r1=1702266&r2=1702267&view=diff
==============================================================================
--- sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/Builder.java [UTF-8]
(original)
+++ sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/Builder.java [UTF-8]
Thu Sep 10 14:36:00 2015
@@ -260,8 +260,8 @@ public abstract class Builder<B extends
 
     /**
      * Creates a new builder initialized to properties of the given object.
-     * The properties recognized by this constructor are documented in the
-     * {@link IdentifiedObjects#getProperties(IdentifiedObject, String...)} method.
+     * The properties recognized by this constructor are documented
+     * {@linkplain IdentifiedObjects#getProperties(IdentifiedObject, String...) here}.
      *
      * @param object The identified object from which to inherit properties, or {@code null}.
      *
@@ -537,9 +537,9 @@ public abstract class Builder<B extends
 
     /**
      * Adds an {@code IdentifiedObject} name fully specified by the given identifier.
-     * This method ignores the authority, {@link #setCodeSpace(Citation, String) code space}
or
-     * {@link #setVersion(String) version} specified to this builder (if any), since the
given
-     * identifier already contains those information.
+     * This method ignores the authority, {@linkplain #setCodeSpace(Citation, String) code
space},
+     * {@linkplain #setVersion(String) version} and {@linkplain #setDescription(CharSequence)
description}
+     * specified to this builder (if any), since the given identifier may already contain
those information.
      *
      * <div class="section">Name and aliases</div>
      * This method can be invoked many times. The first invocation sets the
@@ -563,9 +563,9 @@ public abstract class Builder<B extends
 
     /**
      * Adds an {@code IdentifiedObject} name fully specified by the given generic name.
-     * This method ignores the authority, {@link #setCodeSpace(Citation, String) code space}
or
-     * {@link #setVersion(String) version} specified to this builder (if any), since the
given
-     * generic name already contains those information.
+     * This method ignores the authority, {@linkplain #setCodeSpace(Citation, String) code
space},
+     * {@linkplain #setVersion(String) version} and {@linkplain #setDescription(CharSequence)
description}
+     * specified to this builder (if any), since the given generic name may already contain
those information.
      *
      * <div class="section">Name and aliases</div>
      * This method can be invoked many times. The first invocation sets the

Modified: sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/AbstractDatum.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/AbstractDatum.java?rev=1702267&r1=1702266&r2=1702267&view=diff
==============================================================================
--- sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/AbstractDatum.java
[UTF-8] (original)
+++ sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/AbstractDatum.java
[UTF-8] Thu Sep 10 14:36:00 2015
@@ -25,6 +25,7 @@ import javax.xml.bind.annotation.XmlSeeA
 import org.opengis.util.GenericName;
 import org.opengis.util.InternationalString;
 import org.opengis.metadata.extent.Extent;
+import org.opengis.metadata.citation.Citation;
 import org.opengis.referencing.datum.Datum;
 import org.opengis.referencing.ReferenceIdentifier;
 import org.apache.sis.referencing.AbstractIdentifiedObject;
@@ -34,6 +35,8 @@ import org.apache.sis.util.ComparisonMod
 import org.apache.sis.internal.util.Citations;
 import org.apache.sis.internal.metadata.MetadataUtilities;
 import org.apache.sis.internal.referencing.ReferencingUtilities;
+import org.apache.sis.io.wkt.ElementKind;
+import org.apache.sis.io.wkt.Formatter;
 
 import static org.apache.sis.util.Utilities.deepEquals;
 import static org.apache.sis.util.collection.Containers.property;
@@ -61,7 +64,7 @@ import org.apache.sis.internal.jdk7.Obje
  *
  * @author  Martin Desruisseaux (IRD, Geomatys)
  * @since   0.4
- * @version 0.4
+ * @version 0.6
  * @module
  *
  * @see org.apache.sis.referencing.cs.AbstractCS
@@ -411,6 +414,31 @@ public class AbstractDatum extends Abstr
         return super.computeHashCode() + Objects.hash(anchorDefinition, realizationEpoch,
domainOfValidity, scope);
     }
 
+    /**
+     * Formats the inner part of the <cite>Well Known Text</cite> (WKT) representation
for this datum.
+     * See {@link AbstractIdentifiedObject#formatTo(Formatter)} for more information.
+     *
+     * @param  formatter The formatter where to format the inner content of this WKT element.
+     * @return The {@linkplain org.apache.sis.io.wkt.KeywordCase#CAMEL_CASE CamelCase} keyword
+     *         for the WKT element, or {@code null} if unknown.
+     */
+    @Override
+    protected String formatTo(final Formatter formatter) {
+        final Citation authority = formatter.getNameAuthority();
+        String name = IdentifiedObjects.getName(this, authority);
+        if (name == null) {
+            name = IdentifiedObjects.getName(this, null);
+            if (name == null) { // Should never happen, but be safe.
+                return super.formatTo(formatter);
+            }
+            if ("ESRI".equalsIgnoreCase(Citations.getCodeSpace(authority)) && !name.startsWith(ESRI_PREFIX))
{
+                name = ESRI_PREFIX + name;
+            }
+        }
+        formatter.append(name, ElementKind.DATUM);
+        return null;
+    }
+
 
 
 

Modified: sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/matrix/GeneralMatrix.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/matrix/GeneralMatrix.java?rev=1702267&r1=1702266&r2=1702267&view=diff
==============================================================================
--- sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/matrix/GeneralMatrix.java
[UTF-8] (original)
+++ sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/matrix/GeneralMatrix.java
[UTF-8] Thu Sep 10 14:36:00 2015
@@ -634,6 +634,7 @@ class GeneralMatrix extends MatrixSIS im
      * {@inheritDoc}
      */
     @Override
+    @SuppressWarnings("CloneDoesntCallSuperClone")
     public MatrixSIS clone() {
         return new GeneralMatrix(this);
     }

Modified: sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/matrix/Solver.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/matrix/Solver.java?rev=1702267&r1=1702266&r2=1702267&view=diff
==============================================================================
--- sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/matrix/Solver.java
[UTF-8] (original)
+++ sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/matrix/Solver.java
[UTF-8] Thu Sep 10 14:36:00 2015
@@ -86,6 +86,7 @@ final class Solver implements Matrix { /
      * Returns {@code this} since this matrix is immutable.
      */
     @Override
+    @SuppressWarnings("CloneDoesntCallSuperClone")
     public Matrix clone() {
         return this;
     }

Modified: sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/IdentityTransform.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/IdentityTransform.java?rev=1702267&r1=1702266&r2=1702267&view=diff
==============================================================================
--- sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/IdentityTransform.java
[UTF-8] (original)
+++ sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/IdentityTransform.java
[UTF-8] Thu Sep 10 14:36:00 2015
@@ -87,11 +87,9 @@ final class IdentityTransform extends Ab
                 }
             }
             switch (dimension) {
-                default: candidate = new IdentityTransform(dimension); break;
-                case 1:  candidate = IdentityTransform1D.INSTANCE;     break;
-                case 2:  candidate = new AffineTransform2D();
-                         ((AffineTransform2D) candidate).freeze();
-                         break;
+                default: candidate = new IdentityTransform(dimension);        break;
+                case 1:  candidate = IdentityTransform1D.INSTANCE;            break;
+                case 2:  candidate = new AffineTransform2D(1, 0, 0, 1, 0, 0); break;
             }
             if (dimension < IDENTITIES.length) {
                 IDENTITIES[dimension] = candidate;

Modified: sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/io/wkt/GeodeticObjectParserTest.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/io/wkt/GeodeticObjectParserTest.java?rev=1702267&r1=1702266&r2=1702267&view=diff
==============================================================================
--- sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/io/wkt/GeodeticObjectParserTest.java
[UTF-8] (original)
+++ sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/io/wkt/GeodeticObjectParserTest.java
[UTF-8] Thu Sep 10 14:36:00 2015
@@ -31,6 +31,9 @@ import org.opengis.referencing.Identifie
 import org.opengis.referencing.cs.*;
 import org.opengis.referencing.crs.*;
 import org.opengis.referencing.datum.*;
+import org.opengis.referencing.operation.Matrix;
+import org.opengis.referencing.operation.MathTransform;
+import org.opengis.referencing.operation.NoninvertibleTransformException;
 import org.opengis.parameter.ParameterValue;
 import org.opengis.parameter.ParameterValueGroup;
 import org.apache.sis.internal.metadata.AxisNames;
@@ -38,6 +41,8 @@ import org.apache.sis.referencing.cs.Coo
 import org.apache.sis.referencing.datum.BursaWolfParameters;
 import org.apache.sis.referencing.datum.DefaultGeodeticDatum;
 import org.apache.sis.referencing.factory.GeodeticObjectFactory;
+import org.apache.sis.referencing.operation.transform.MathTransforms;
+import org.apache.sis.referencing.operation.transform.LinearTransform;
 import org.apache.sis.test.DependsOnMethod;
 import org.apache.sis.test.DependsOn;
 import org.apache.sis.test.TestCase;
@@ -516,6 +521,100 @@ public final strictfp class GeodeticObje
     }
 
     /**
+     * Tests the parsing of a projected CRS from a WKT 1 string with authority and Bursa-Wolf
parameters.
+     *
+     * @throws ParseException if the parsing failed.
+     */
+    @Test
+    @DependsOnMethod("testProjectedCRS")
+    public void testProjectedWithID() throws ParseException {
+        final ProjectedCRS crs = parse(ProjectedCRS.class,
+               "PROJCS[“OSGB 1936 / British National Grid”,\n" +
+               "  GEOGCS[“OSGB 1936”,\n" +
+               "    DATUM[“OSGB_1936”,\n" +
+               "      SPHEROID[“Airy 1830”, 6377563.396, 299.3249646, AUTHORITY[“EPSG”,
“7001”]],\n" +
+               "      TOWGS84[375.0, -111.0, 431.0, 0.0, 0.0, 0.0, 0.0],\n" +
+               "      AUTHORITY[“EPSG”, “6277”]],\n" +
+               "      PRIMEM[“Greenwich”,0.0, AUTHORITY[“EPSG”, “8901”]],\n"
+
+               "    UNIT[“DMSH”,0.0174532925199433],\n" +
+               "    AXIS[“Lat”,NORTH],AXIS[“Long”,EAST], AUTHORITY[“EPSG”, “4277”]],\n"
+
+               "  PROJECTION[“Transverse_Mercator”],\n" +
+               "  PARAMETER[“latitude_of_origin”, 49.0],\n" +
+               "  PARAMETER[“central_meridian”, -2.0],\n" +
+               "  PARAMETER[“scale_factor”, 0.999601272],\n" +
+               "  PARAMETER[“false_easting”, 400000.0],\n" +
+               "  PARAMETER[“false_northing”, -100000.0],\n" +
+               "  UNIT[“metre”, 1.0, AUTHORITY[“EPSG”, “9001”]],\n" +
+               "  AXIS[“E”,EAST],\n" +
+               "  AXIS[“N”,NORTH],\n" +
+               "  AUTHORITY[“EPSG”, “27700”]]");
+
+        assertNameAndIdentifierEqual("OSGB 1936 / British National Grid", 27700, crs);
+        assertNameAndIdentifierEqual("OSGB 1936", 4277, crs.getBaseCRS());
+        assertNameAndIdentifierEqual("OSGB_1936", 6277, crs.getDatum());
+        verifyProjectedCS(crs.getCoordinateSystem(), SI.METRE);
+
+        final ParameterValueGroup param = crs.getConversionFromBase().getParameterValues();
+        assertEquals("Transverse Mercator", crs.getConversionFromBase().getMethod().getName().getCode());
+        assertEquals("semi_major",   6377563.396, param.parameter("semi_major"        ).doubleValue(),
1E-4);
+        assertEquals("semi_minor",   6356256.909, param.parameter("semi_minor"        ).doubleValue(),
1E-3);
+        assertEquals("latitude_of_origin",  49.0, param.parameter("latitude_of_origin").doubleValue(),
1E-8);
+        assertEquals("central_meridian",    -2.0, param.parameter("central_meridian"  ).doubleValue(),
1E-8);
+        assertEquals("scale_factor",      0.9996, param.parameter("scale_factor"      ).doubleValue(),
1E-5);
+        assertEquals("false_easting",   400000.0, param.parameter("false_easting"     ).doubleValue(),
1E-4);
+        assertEquals("false_northing", -100000.0, param.parameter("false_northing"    ).doubleValue(),
1E-4);
+
+        final BursaWolfParameters[] bwp = ((DefaultGeodeticDatum) crs.getDatum()).getBursaWolfParameters();
+        assertEquals("BursaWolfParameters", 1, bwp.length);
+        assertArrayEquals("BursaWolfParameters", new double[] {375, -111, 431}, bwp[0].getValues(),
STRICT);
+    }
+
+    /**
+     * Tests the parsing of a projected CRS with feet units.
+     *
+     * @throws ParseException if the parsing failed.
+     */
+    @Test
+    @DependsOnMethod("testProjectedCRS")
+    public void testProjectedWithFeetUnits() throws ParseException {
+        final ProjectedCRS crs = parse(ProjectedCRS.class,
+               "PROJCS[“TransverseMercator”,\n" +
+               "  GEOGCS[“Sphere”,\n" +
+               "    DATUM[“Sphere”,\n" +
+               "      SPHEROID[“Sphere”, 6370997.0, 0.0],\n" +
+               "      TOWGS84[0, 0, 0, 0, 0, 0, 0]],\n" +
+               "      PRIMEM[“Greenwich”, 0.0],\n" +
+               "    UNIT[“degree”, 0.017453292519943295],\n" +
+               "    AXIS[“Longitude”, EAST],\n" +
+               "    AXIS[“Latitude”, NORTH]],\n" +
+               "  PROJECTION[“Transverse_Mercator”,\n" +
+               "    AUTHORITY[“OGC”, “Transverse_Mercator”]],\n" +
+               "  PARAMETER[“central_meridian”, 170.0],\n" +
+               "  PARAMETER[“latitude_of_origin”, 50.0],\n" +
+               "  PARAMETER[“scale_factor”, 0.95],\n" +
+               "  PARAMETER[“false_easting”, 0.0],\n" +
+               "  PARAMETER[“false_northing”, 0.0],\n" +
+               "  UNIT[“feet”, 0.304800609601219],\n" +
+               "  AXIS[“E”, EAST],\n" +
+               "  AXIS[“N”, NORTH]]");
+
+        assertNameAndIdentifierEqual("TransverseMercator", 0, crs);
+        assertNameAndIdentifierEqual("Sphere", 0, crs.getBaseCRS());
+        assertNameAndIdentifierEqual("Sphere", 0, crs.getDatum());
+        verifyProjectedCS(crs.getCoordinateSystem(), NonSI.FOOT_SURVEY_US);
+
+        final ParameterValueGroup param = crs.getConversionFromBase().getParameterValues();
+        assertEquals("Transverse Mercator", crs.getConversionFromBase().getMethod().getName().getCode());
+        assertEquals("semi_major",     6370997.0, param.parameter("semi_major"        ).doubleValue(),
1E-5);
+        assertEquals("semi_minor",     6370997.0, param.parameter("semi_minor"        ).doubleValue(),
1E-5);
+        assertEquals("latitude_of_origin",  50.0, param.parameter("latitude_of_origin").doubleValue(),
1E-8);
+        assertEquals("central_meridian",   170.0, param.parameter("central_meridian"  ).doubleValue(),
1E-8);
+        assertEquals("scale_factor",        0.95, param.parameter("scale_factor"      ).doubleValue(),
1E-8);
+        assertEquals("false_easting",        0.0, param.parameter("false_easting"     ).doubleValue(),
1E-8);
+        assertEquals("false_northing",       0.0, param.parameter("false_northing"    ).doubleValue(),
1E-8);
+    }
+
+    /**
      * Tests the parsing of a projected CRS using angular values in grades instead than degrees
      * and in lengths in kilometres instead than metres.
      *
@@ -679,6 +778,101 @@ public final strictfp class GeodeticObje
     }
 
     /**
+     * Parses a test CRS north or south oriented.
+     * If the CRS is fully south-oriented with 0.0 northing, then it should be the EPSG:22285
one.
+     */
+    private ProjectedCRS parseTransverseMercator(final boolean methodSouth,
+            final boolean axisSouth, final double northing) throws ParseException
+    {
+        final String method = methodSouth ? "Transverse Mercator (South Orientated)" : "Transverse
Mercator";
+        final String axis = axisSouth ? "“Southing”, SOUTH" : "“Northing”, NORTH";
+        return parse(ProjectedCRS.class,
+                "PROJCS[“South African Coordinate System zone 25”, " +
+                  "GEOGCS[“Cape”, " +
+                    "DATUM[“Cape”, " +
+                      "SPHEROID[“Clarke 1880 (Arc)”, 6378249.145, 293.4663077, AUTHORITY[“EPSG”,“7013”]],
" +
+                      "TOWGS84[-136.0, -108.0, -292.0], " +
+                      "AUTHORITY[“EPSG”,“6222”]], " +
+                    "PRIMEM[“Greenwich”, 0.0, AUTHORITY[“EPSG”,“8901”]], " +
+                    "UNIT[“degree”, 0.017453292519943295], " +
+                    "AXIS[“Geodetic latitude”, NORTH], " +
+                    "AXIS[“Geodetic longitude”, EAST], " +
+                    "AUTHORITY[“EPSG”,“4222”]], " +
+                  "PROJECTION[“" + method + "”], " +
+                  "PARAMETER[“central_meridian”, 25.0], " +
+                  "PARAMETER[“latitude_of_origin”, 0.0], " +
+                  "PARAMETER[“scale_factor”, 1.0], " +
+                  "PARAMETER[“false_easting”, 0.0], " +
+                  "PARAMETER[“false_northing”, " + northing + "], " +
+                  "UNIT[“m”, 1.0], " +
+                  "AXIS[“Westing”, WEST], " +
+                  "AXIS[" + axis + "]]");
+    }
+
+    /**
+     * Returns the conversion from {@code north} to {@code south}.
+     */
+    private static Matrix conversion(final ProjectedCRS north, final ProjectedCRS south)
+            throws NoninvertibleTransformException
+    {
+        final MathTransform transform = MathTransforms.concatenate(
+                north.getConversionFromBase().getMathTransform().inverse(),
+                south.getConversionFromBase().getMathTransform());
+        assertInstanceOf("North to South", LinearTransform.class, transform);
+        return ((LinearTransform) transform).getMatrix();
+    }
+
+    /**
+     * Tests the {@link MathTransform} between North-Orientated and South-Orientated cases.
+     *
+     * @throws ParseException if the parsing failed.
+     * @throws NoninvertibleTransformException if computation of the conversion from North-Orientated
+     *         to South-Orientated failed.
+     */
+    @Test
+    @DependsOnMethod("testProjectedCRS")
+    public void testMathTransform() throws ParseException, NoninvertibleTransformException
{
+        /*
+         * Test "Transverse Mercator" (not south-oriented) with an axis oriented toward south.
+         * The 'south' transform is actually the usual Transverse Mercator projection, despite
+         * having axis oriented toward South.  Consequently the "False Northing" parameter
has
+         * the same meaning for those two CRS. Since we assigned the same False Northing
value,
+         * those two CRS have their "False origin" at the same location. This is why conversion
+         * from 'south' to 'north' introduce no translation, only a reversal of y axis.
+         */
+        ProjectedCRS north = parseTransverseMercator(false, false, 1000);
+        assertEquals(AxisDirection.WEST,  north.getCoordinateSystem().getAxis(0).getDirection());
+        assertEquals(AxisDirection.NORTH, north.getCoordinateSystem().getAxis(1).getDirection());
+
+        ProjectedCRS south = parseTransverseMercator(false, true, 1000);
+        assertEquals(AxisDirection.WEST,  south.getCoordinateSystem().getAxis(0).getDirection());
+        assertEquals(AxisDirection.SOUTH, south.getCoordinateSystem().getAxis(1).getDirection());
+
+        Matrix matrix = conversion(north, south);
+        assertEquals("West direction should be unchanged. ",      +1, matrix.getElement(0,0),
STRICT);
+        assertEquals("North-South direction should be reverted.", -1, matrix.getElement(1,1),
STRICT);
+        assertEquals("No easting expected.",                       0, matrix.getElement(0,2),
STRICT);
+        assertEquals("No northing expected.",                      0, matrix.getElement(1,2),
STRICT);
+        assertDiagonalEquals(new double[] {+1, -1, 1}, true, matrix, STRICT);
+        /*
+         * Test "Transverse Mercator South Orientated". In this projection, the "False Northing"
parameter
+         * is actually a "False Southing". It may sound surprising, but "South Orientated"
projections are
+         * defined that way.  For converting from our CRS having a False Northing of 1000
to a CRS without
+         * False Northing or Southing, we must subtract 1000 from the axis which is oriented
toward North.
+         * This means adding 1000 if the axis is rather oriented toward South. Then we add
another 1000 m
+         * (the value specified in the line just below) toward South.
+         */
+        south = parseTransverseMercator(true, true, 1000);  // "False Southing" of 1000 metres.
+        assertEquals(AxisDirection.WEST,  south.getCoordinateSystem().getAxis(0).getDirection());
+        assertEquals(AxisDirection.SOUTH, south.getCoordinateSystem().getAxis(1).getDirection());
+        matrix = conversion(north, south);
+        assertEquals("West direction should be unchanged. ",      +1, matrix.getElement(0,0),
STRICT);
+        assertEquals("North-South direction should be reverted.", -1, matrix.getElement(1,1),
STRICT);
+        assertEquals("No easting expected.",                       0, matrix.getElement(0,2),
STRICT);
+        assertEquals("Northing expected.",                      2000, matrix.getElement(1,2),
STRICT);
+    }
+
+    /**
      * Tests the parsing of an engineering CRS from a WKT 2 string.
      *
      * @throws ParseException if the parsing failed.

Modified: sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/io/wkt/WKTFormatTest.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/io/wkt/WKTFormatTest.java?rev=1702267&r1=1702266&r2=1702267&view=diff
==============================================================================
--- sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/io/wkt/WKTFormatTest.java
[UTF-8] (original)
+++ sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/io/wkt/WKTFormatTest.java
[UTF-8] Thu Sep 10 14:36:00 2015
@@ -20,6 +20,8 @@ import java.util.Collections;
 import java.text.ParseException;
 import javax.measure.unit.NonSI;
 import org.opengis.referencing.crs.VerticalCRS;
+import org.apache.sis.metadata.iso.citation.Citations;
+import org.apache.sis.referencing.crs.DefaultProjectedCRS;
 import org.apache.sis.referencing.datum.DefaultPrimeMeridian;
 import org.apache.sis.test.DependsOnMethod;
 import org.apache.sis.test.DependsOn;
@@ -234,6 +236,143 @@ public final strictfp class WKTFormatTes
     }
 
     /**
+     * Tests the formatting using the name of different authorities.
+     * This test uses WKT 1 for parsing and formatting.
+     *
+     * @throws ParseException if the parsing failed.
+     */
+    @Test
+    public void testVariousConventions() throws ParseException {
+        final Symbols symbols = new Symbols(Symbols.SQUARE_BRACKETS);
+        symbols.setPairedQuotes("“”");
+        parser = format = new WKTFormat(null, null);
+        format.setSymbols(symbols);
+        final DefaultProjectedCRS crs = (DefaultProjectedCRS) parser.parseObject(
+            "PROJCS[“OSGB 1936 / British National Grid”,\n" +
+            "  GEOGCS[“OSGB 1936”,\n" +
+            "    DATUM[“OSGB_1936”,\n" +
+            "      SPHEROID[“Airy 1830”, 6377563.396, 299.3249646],\n" +
+            "      TOWGS84[375.0, -111.0, 431.0, 0.0, 0.0, 0.0, 0.0]],\n" +
+            "      PRIMEM[“Greenwich”,0.0],\n" +
+            "    UNIT[“DMSH”,0.0174532925199433],\n" +
+            "    AXIS[“Lat”,NORTH],AXIS[“Long”,EAST]],\n" +
+            "  PROJECTION[“Transverse_Mercator”],\n" +
+            "  PARAMETER[“latitude_of_origin”, 49.0],\n" +
+            "  PARAMETER[“central_meridian”, -2.0],\n" +
+            "  PARAMETER[“scale_factor”, 0.999601272],\n" +
+            "  PARAMETER[“false_easting”, 400000.0],\n" +
+            "  PARAMETER[“false_northing”, -100000.0],\n" +
+            "  UNIT[“metre”, 1],\n" +
+            "  AXIS[“E”,EAST],\n" +
+            "  AXIS[“N”,NORTH]]");
+        /*
+         * Formats using OGC identifiers. Use of OGC identifiers is implicit with Convention.WKT1,
unless we
+         * set explicitely another authority. The result should be the same than the above
string, except:
+         *
+         *   - The TOWGS84 parameters have been trimmed to 3 values.
+         *   - The AUTHORITY elements has been inferred for the PROJECTION element.
+         *   - "Latitude of origin" parameter is before "central meridian" parameter.
+         */
+        format.setConvention(Convention.WKT1);
+        assertMultilinesEquals(
+            "PROJCS[“OSGB 1936 / British National Grid”,\n" +
+            "  GEOGCS[“OSGB 1936”,\n" +
+            "    DATUM[“OSGB_1936”,\n" +
+            "      SPHEROID[“Airy 1830”, 6377563.396, 299.3249646],\n" +
+            "      TOWGS84[375.0, -111.0, 431.0]],\n" +                             // Trimmed
to 3 parameters.
+            "      PRIMEM[“Greenwich”, 0.0],\n" +
+            "    UNIT[“degree”, 0.017453292519943295],\n" +
+            "    AXIS[“Latitude”, NORTH],\n" +
+            "    AXIS[“Longitude”, EAST]],\n" +
+            "  PROJECTION[“Transverse_Mercator”, AUTHORITY[“EPSG”, “9807”]],\n"
+   // AUTHORITY code automatically found.
+            "  PARAMETER[“latitude_of_origin”, 49.0],\n" +                          //
Sorted before central meridian.
+            "  PARAMETER[“central_meridian”, -2.0],\n" +
+            "  PARAMETER[“scale_factor”, 0.999601272],\n" +
+            "  PARAMETER[“false_easting”, 400000.0],\n" +
+            "  PARAMETER[“false_northing”, -100000.0],\n" +
+            "  UNIT[“metre”, 1],\n" +
+            "  AXIS[“Easting”, EAST],\n" +
+            "  AXIS[“Northing”, NORTH]]",
+            format.format(crs));
+        /*
+         * Formats using GeoTiff identifiers. We should get different strings in PROJECTION[...]
+         * and PARAMETER[...] elements, but the other ones (especially DATUM[...]) are unchanged.
+         */
+        format.setNameAuthority(Citations.GEOTIFF);
+        assertMultilinesEquals(
+            "PROJCS[“OSGB 1936 / British National Grid”,\n" +
+            "  GEOGCS[“OSGB 1936”,\n" +
+            "    DATUM[“OSGB_1936”,\n" +
+            "      SPHEROID[“Airy 1830”, 6377563.396, 299.3249646],\n" +
+            "      TOWGS84[375.0, -111.0, 431.0]],\n" +
+            "      PRIMEM[“Greenwich”, 0.0],\n" +
+            "    UNIT[“degree”, 0.017453292519943295],\n" +
+            "    AXIS[“Latitude”, NORTH],\n" +
+            "    AXIS[“Longitude”, EAST]],\n" +
+            "  PROJECTION[“CT_TransverseMercator”, AUTHORITY[“GeoTIFF”, “1”]],\n"
+
+            "  PARAMETER[“NatOriginLat”, 49.0],\n" +
+            "  PARAMETER[“NatOriginLong”, -2.0],\n" +
+            "  PARAMETER[“ScaleAtNatOrigin”, 0.999601272],\n" +
+            "  PARAMETER[“FalseEasting”, 400000.0],\n" +
+            "  PARAMETER[“FalseNorthing”, -100000.0],\n" +
+            "  UNIT[“metre”, 1],\n" +
+            "  AXIS[“Easting”, EAST],\n" +
+            "  AXIS[“Northing”, NORTH]]",
+            format.format(crs));
+        /*
+         * Formats using ESRI identifiers. The most important change we are looking for is
+         * the name inside DATUM[...].
+         */
+        format.setNameAuthority(Citations.ESRI);
+        format.setConvention(Convention.WKT1_COMMON_UNITS);
+        assertMultilinesEquals(
+            "PROJCS[“OSGB 1936 / British National Grid”,\n" +
+            "  GEOGCS[“OSGB 1936”,\n" +
+            "    DATUM[“D_OSGB_1936”,\n" +
+            "      SPHEROID[“Airy 1830”, 6377563.396, 299.3249646],\n" +
+            "      TOWGS84[375.0, -111.0, 431.0]],\n" +
+            "      PRIMEM[“Greenwich”, 0.0],\n" +
+            "    UNIT[“degree”, 0.017453292519943295],\n" +
+            "    AXIS[“Latitude”, NORTH],\n" +
+            "    AXIS[“Longitude”, EAST]],\n" +
+            "  PROJECTION[“Transverse_Mercator”, AUTHORITY[“EPSG”, “9807”]],\n"
+
+            "  PARAMETER[“Latitude_Of_Origin”, 49.0],\n" +
+            "  PARAMETER[“Central_Meridian”, -2.0],\n" +
+            "  PARAMETER[“Scale_Factor”, 0.999601272],\n" +
+            "  PARAMETER[“False_Easting”, 400000.0],\n" +
+            "  PARAMETER[“False_Northing”, -100000.0],\n" +
+            "  UNIT[“meter”, 1],\n" +
+            "  AXIS[“Easting”, EAST],\n" +
+            "  AXIS[“Northing”, NORTH]]",
+            format.format(crs));
+        /*
+         * Formats using EPSG identifiers. We expect different names in
+         * DATUM[...], PROJECTION[...] and PARAMETER[...].
+         */
+        format.setNameAuthority(Citations.EPSG);
+        assertMultilinesEquals(
+            "PROJCS[“OSGB 1936 / British National Grid”,\n" +
+            "  GEOGCS[“OSGB 1936”,\n" +
+            "    DATUM[“OSGB_1936”,\n" +
+            "      SPHEROID[“Airy 1830”, 6377563.396, 299.3249646],\n" +
+            "      TOWGS84[375.0, -111.0, 431.0]],\n" +
+            "      PRIMEM[“Greenwich”, 0.0],\n" +
+            "    UNIT[“degree”, 0.017453292519943295],\n" +
+            "    AXIS[“Latitude”, NORTH],\n" +
+            "    AXIS[“Longitude”, EAST]],\n" +
+            "  PROJECTION[“Transverse Mercator”, AUTHORITY[“EPSG”, “9807”]],\n"
+
+            "  PARAMETER[“Latitude of natural origin”, 49.0],\n" +
+            "  PARAMETER[“Longitude of natural origin”, -2.0],\n" +
+            "  PARAMETER[“Scale factor at natural origin”, 0.999601272],\n" +
+            "  PARAMETER[“False easting”, 400000.0],\n" +
+            "  PARAMETER[“False northing”, -100000.0],\n" +
+            "  UNIT[“meter”, 1],\n" +
+            "  AXIS[“Easting”, EAST],\n" +
+            "  AXIS[“Northing”, NORTH]]",
+            format.format(crs));
+    }
+
+    /**
      * Tests the production of a warning messages when the WKT contains unformattable elements.
      *
      * @throws ParseException if the parsing (tested after formatting) failed.

Modified: sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/ConcatenatedTransformTest.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/ConcatenatedTransformTest.java?rev=1702267&r1=1702266&r2=1702267&view=diff
==============================================================================
--- sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/ConcatenatedTransformTest.java
[UTF-8] (original)
+++ sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/ConcatenatedTransformTest.java
[UTF-8] Thu Sep 10 14:36:00 2015
@@ -44,13 +44,8 @@ public final strictfp class Concatenated
      */
     @Test
     public void testDirect2D() throws TransformException {
-        final AffineTransform2D first = new AffineTransform2D();
-        first.translate(2,4);
-        first.freeze();
-
-        final AffineTransform2D second = new AffineTransform2D();
-        second.translate(0.25, 0.75);
-        second.freeze();
+        final AffineTransform2D first  = new AffineTransform2D(1, 0, 0, 1, 2.00, 4.00); 
  // translate(2, 4)
+        final AffineTransform2D second = new AffineTransform2D(1, 0, 0, 1, 0.25, 0.75); 
  // translate(0.25, 0.75);
 
         // Direct for 2D case.
         tolerance = 1E-10;
@@ -93,9 +88,7 @@ public final strictfp class Concatenated
     public void testGeneric() throws TransformException {
         final MathTransform first = null; //MathTransforms.dimensionFilter(4, new int[] {1,3});
 
-        final AffineTransform2D second = new AffineTransform2D();
-        second.scale(0.5, 0.25);
-        second.freeze();
+        final AffineTransform2D second = new AffineTransform2D(0.5, 0, 0, 0.25, 0, 0);  //
scale(0.5, 0.25);
 
         transform = new ConcatenatedTransform(first, second);
         isInverseTransformSupported = false;



Mime
View raw message