Author: desruisseaux
Date: Tue Mar 17 20:25:34 2015
New Revision: 1667393

URL: http://svn.apache.org/r1667393
Log:
Referencing: added a small test for Mercator parameters.

Added:
    
sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/provider/MapProjectionTest.java
   (with props)
Modified:
    
sis/branches/JDK8/core/sis-metadata/src/test/java/org/apache/sis/test/MetadataAssert.java
    
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/MapProjection.java
    
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/parameter/ParameterTableRow.java
    
sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/provider/AllProvidersTest.java
    
sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/parameter/TensorParametersTest.java
    
sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/DefaultOperationMethodTest.java
    
sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/test/ReferencingAssert.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/test/java/org/apache/sis/test/MetadataAssert.java
URL: 
http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-metadata/src/test/java/org/apache/sis/test/MetadataAssert.java?rev=1667393&r1=1667392&r2=1667393&view=diff
==============================================================================
--- 
sis/branches/JDK8/core/sis-metadata/src/test/java/org/apache/sis/test/MetadataAssert.java
 [UTF-8] (original)
+++ 
sis/branches/JDK8/core/sis-metadata/src/test/java/org/apache/sis/test/MetadataAssert.java
 [UTF-8] Tue Mar 17 20:25:34 2015
@@ -22,9 +22,6 @@ import org.opengis.referencing.Identifie
 import org.apache.sis.io.wkt.Symbols;
 import org.apache.sis.io.wkt.WKTFormat;
 import org.apache.sis.io.wkt.Convention;
-import org.apache.sis.metadata.iso.citation.Citations;
-
-import static org.apache.sis.internal.util.Constants.EPSG;
 
 
 /**
@@ -56,22 +53,6 @@ public strictfp class MetadataAssert ext
     }
 
     /**
-     * Asserts that the given identifier has the expected code and the {@code 
"EPSG"} code space.
-     * The authority is expected to have the {@code "OGP"} title or alternate 
title.
-     *
-     * @param expected   The expected identifier code.
-     * @param identifier The identifier to verify.
-     *
-     * @since 0.5
-     */
-    public static void assertEpsgIdentifierEquals(final String expected, final 
Identifier identifier) {
-        assertNotNull(identifier);
-        assertEquals("code",      expected, identifier.getCode());
-        assertEquals("codeSpace", EPSG,  identifier.getCodeSpace());
-        assertEquals("authority", "OGP", 
Citations.getIdentifier(identifier.getAuthority()));
-    }
-
-    /**
      * Asserts that the given collection contains exactly one identifier with 
the given
      * {@linkplain Identifier#getCode() code}. The {@linkplain 
Identifier#getCodeSpace()
      * code space} and authority are ignored.

Modified: 
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/MapProjection.java
URL: 
http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/MapProjection.java?rev=1667393&r1=1667392&r2=1667393&view=diff
==============================================================================
--- 
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/MapProjection.java
 [UTF-8] (original)
+++ 
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/MapProjection.java
 [UTF-8] Tue Mar 17 20:25:34 2015
@@ -28,9 +28,10 @@ import org.opengis.referencing.operation
 import org.apache.sis.internal.util.Constants;
 import org.apache.sis.measure.MeasurementRange;
 import org.apache.sis.referencing.NamedIdentifier;
+import org.apache.sis.metadata.iso.citation.Citations;
 import org.apache.sis.parameter.DefaultParameterDescriptor;
 
-import static org.apache.sis.metadata.iso.citation.Citations.*;
+import static org.opengis.metadata.Identifier.AUTHORITY_KEY;
 
 
 /**
@@ -73,24 +74,25 @@ public abstract class MapProjection exte
     static {
         final MeasurementRange<Double> valueDomain = 
MeasurementRange.createGreaterThan(0, SI.METRE);
         final GenericName[] aliases = {
-            new NamedIdentifier(ESRI,    "Semi_Major"),
-            new NamedIdentifier(NETCDF,  "semi_major_axis"),
-            new NamedIdentifier(GEOTIFF, "SemiMajor"),
-            new NamedIdentifier(PROJ4,   "a")
+            new NamedIdentifier(Citations.ESRI,    "Semi_Major"),
+            new NamedIdentifier(Citations.NETCDF,  "semi_major_axis"),
+            new NamedIdentifier(Citations.GEOTIFF, "SemiMajor"),
+            new NamedIdentifier(Citations.PROJ4,   "a")
         };
         final Map<String,Object> properties = new HashMap<>(4);
-        properties.put(NAME_KEY,  Constants.SEMI_MAJOR);
-        properties.put(ALIAS_KEY, aliases);
+        properties.put(AUTHORITY_KEY, Citations.OGC);
+        properties.put(NAME_KEY,      Constants.SEMI_MAJOR);
+        properties.put(ALIAS_KEY,     aliases);
         SEMI_MAJOR = new DefaultParameterDescriptor<>(properties, 1, 1, 
Double.class, valueDomain, null, null);
         /*
          * Change in-place the name and aliases (we do not need to create new 
objects)
          * before to create the SEMI_MINOR descriptor.
          */
         properties.put(NAME_KEY, Constants.SEMI_MINOR);
-        aliases[0] = new NamedIdentifier(ESRI,    "Semi_Minor");
-        aliases[1] = new NamedIdentifier(NETCDF,  "semi_minor_axis");
-        aliases[2] = new NamedIdentifier(GEOTIFF, "SemiMinor");
-        aliases[3] = new NamedIdentifier(PROJ4,   "b");
+        aliases[0] = new NamedIdentifier(Citations.ESRI,    "Semi_Minor");
+        aliases[1] = new NamedIdentifier(Citations.NETCDF,  "semi_minor_axis");
+        aliases[2] = new NamedIdentifier(Citations.GEOTIFF, "SemiMinor");
+        aliases[3] = new NamedIdentifier(Citations.PROJ4,   "b");
         SEMI_MINOR = new DefaultParameterDescriptor<>(properties, 1, 1, 
Double.class, valueDomain, null, null);
     }
 

Modified: 
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/parameter/ParameterTableRow.java
URL: 
http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/parameter/ParameterTableRow.java?rev=1667393&r1=1667392&r2=1667393&view=diff
==============================================================================
--- 
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/parameter/ParameterTableRow.java
 [UTF-8] (original)
+++ 
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/parameter/ParameterTableRow.java
 [UTF-8] Tue Mar 17 20:25:34 2015
@@ -43,6 +43,7 @@ import org.apache.sis.internal.util.X364
 
 import static org.apache.sis.internal.util.X364.*;
 import static org.apache.sis.util.CharSequences.spaces;
+import static org.apache.sis.util.iso.DefaultNameSpace.DEFAULT_SEPARATOR;
 
 
 /**
@@ -308,7 +309,7 @@ final class ParameterTableRow {
             final Colors colors, final boolean colorsForRows, final String 
lineSeparator) throws IOException
     {
         if (codespaceWidth != 0) {
-            codespaceWidth++; // Add a space between codespace and code in 
e.g. "OGC: Mercator".
+            codespaceWidth += 2; // Add a colon and space between codespace 
and code in e.g. "OGC: Mercator".
         }
         boolean isNewLine = false;
         for (final Map.Entry<String,Set<Object>> entry : 
identifiers.entrySet()) {
@@ -329,9 +330,9 @@ final class ParameterTableRow {
                     int pad = codespaceWidth;
                     if (codespace != null) {
                         writeColor(out, FAINT, colorsForRows);
-                        out.append(codespace).append(':');
+                        out.append(codespace).append(DEFAULT_SEPARATOR);
                         writeColor(out, NORMAL, colorsForRows);
-                        pad -= codespace.length();
+                        pad -= (codespace.length() + 1);
                     }
                     out.append(spaces(pad));
                 }

Modified: 
sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/provider/AllProvidersTest.java
URL: 
http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/provider/AllProvidersTest.java?rev=1667393&r1=1667392&r2=1667393&view=diff
==============================================================================
--- 
sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/provider/AllProvidersTest.java
 [UTF-8] (original)
+++ 
sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/provider/AllProvidersTest.java
 [UTF-8] Tue Mar 17 20:25:34 2015
@@ -40,7 +40,8 @@ import static org.junit.Assert.*;
  */
 @DependsOn({
     org.apache.sis.referencing.operation.DefaultOperationMethodTest.class,
-    AffineTest.class
+    AffineTest.class,
+    MapProjectionTest.class
 })
 public final strictfp class AllProvidersTest extends TestCase {
     /**

Added: 
sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/provider/MapProjectionTest.java
URL: 
http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/provider/MapProjectionTest.java?rev=1667393&view=auto
==============================================================================
--- 
sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/provider/MapProjectionTest.java
 (added)
+++ 
sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/provider/MapProjectionTest.java
 [UTF-8] Tue Mar 17 20:25:34 2015
@@ -0,0 +1,56 @@
+/*
+ * 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 org.apache.sis.internal.util.Constants;
+import org.apache.sis.test.TestCase;
+import org.junit.Test;
+
+import static org.apache.sis.test.ReferencingAssert.*;
+
+
+/**
+ * Verifies some parameters of {@link MapProjection} and a few subclasses.
+ *
+ * @author  Martin Desruisseaux (Geomatys)
+ * @since   0.6
+ * @version 0.6
+ * @module
+ */
+public final strictfp class MapProjectionTest extends TestCase {
+    /**
+     * Verifies {@link MapProjection#SEMI_MAJOR} and {@link 
MapProjection#SEMI_MINOR} parameter descriptors.
+     */
+    @Test
+    public void testSemiAxes() {
+        assertOgcIdentifierEquals(Constants.SEMI_MAJOR, 
MapProjection.SEMI_MAJOR.getName());
+        assertOgcIdentifierEquals(Constants.SEMI_MINOR, 
MapProjection.SEMI_MINOR.getName());
+    }
+
+    /**
+     * Verifies some {@link Mercator1SP} parameter descriptors.
+     */
+    @Test
+    public void testMercator1SP() {
+        assertEpsgIdentifierEquals("Mercator (variant A)",           new 
Mercator1SP().getName());
+        assertEpsgIdentifierEquals("Latitude of natural origin",     
Mercator1SP.LATITUDE_OF_ORIGIN.getName());
+        assertEpsgIdentifierEquals("Longitude of natural origin",    
Mercator1SP.CENTRAL_MERIDIAN  .getName());
+        assertEpsgIdentifierEquals("Scale factor at natural origin", 
Mercator1SP.SCALE_FACTOR      .getName());
+        assertEpsgIdentifierEquals("False easting",                  
Mercator1SP.FALSE_EASTING     .getName());
+        assertEpsgIdentifierEquals("False northing",                 
Mercator1SP.FALSE_NORTHING    .getName());
+    }
+}

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

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

Modified: 
sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/parameter/TensorParametersTest.java
URL: 
http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/parameter/TensorParametersTest.java?rev=1667393&r1=1667392&r2=1667393&view=diff
==============================================================================
--- 
sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/parameter/TensorParametersTest.java
 [UTF-8] (original)
+++ 
sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/parameter/TensorParametersTest.java
 [UTF-8] Tue Mar 17 20:25:34 2015
@@ -161,7 +161,7 @@ public strictfp class TensorParametersTe
     {
         assertEquals("name", names[row][column], actual.getName().getCode());
         assertAliasTipEquals((aliases != null) ? aliases[row][column] : null, 
actual);
-        assertIdentifierEqualsEPSG((identifiers != null) ? 
identifiers[row][column] : 0, actual);
+        assertEpsgIdentifierEquals((identifiers != null) ? 
identifiers[row][column] : 0, actual.getIdentifiers());
         assertEquals("defaultValue", defaultValue, actual.getDefaultValue());
     }
 

Modified: 
sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/DefaultOperationMethodTest.java
URL: 
http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/DefaultOperationMethodTest.java?rev=1667393&r1=1667392&r2=1667393&view=diff
==============================================================================
--- 
sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/DefaultOperationMethodTest.java
 [UTF-8] (original)
+++ 
sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/DefaultOperationMethodTest.java
 [UTF-8] Tue Mar 17 20:25:34 2015
@@ -32,8 +32,7 @@ import org.apache.sis.test.DependsOn;
 import org.apache.sis.test.TestCase;
 import org.junit.Test;
 
-import static org.apache.sis.test.MetadataAssert.*;
-import static org.apache.sis.test.TestUtilities.getSingleton;
+import static org.apache.sis.test.ReferencingAssert.*;
 
 
 /**
@@ -87,7 +86,7 @@ public final strictfp class DefaultOpera
     public void testConstruction() {
         final OperationMethod method = create("Mercator (variant A)", "9804", 
"EPSG guidance note #7-2", 2);
         assertEpsgIdentifierEquals("Mercator (variant A)", method.getName());
-        assertEpsgIdentifierEquals("9804", 
getSingleton(method.getIdentifiers()));
+        assertEpsgIdentifierEquals(9804, method.getIdentifiers());
         assertEquals("formula", "EPSG guidance note #7-2", 
method.getFormula().getCitation().getTitle().toString());
         assertEquals("sourceDimensions", Integer.valueOf(2), 
method.getSourceDimensions());
         assertEquals("targetDimensions", Integer.valueOf(2), 
method.getTargetDimensions());

Modified: 
sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/test/ReferencingAssert.java
URL: 
http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/test/ReferencingAssert.java?rev=1667393&r1=1667392&r2=1667393&view=diff
==============================================================================
--- 
sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/test/ReferencingAssert.java
 [UTF-8] (original)
+++ 
sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/test/ReferencingAssert.java
 [UTF-8] Tue Mar 17 20:25:34 2015
@@ -17,7 +17,6 @@
 package org.apache.sis.test;
 
 import java.util.Collection;
-import java.util.Set;
 import java.awt.geom.Rectangle2D;
 import java.awt.geom.RectangularShape;
 import java.awt.geom.AffineTransform;
@@ -34,13 +33,14 @@ import org.opengis.referencing.cs.AxisDi
 import org.opengis.referencing.cs.CoordinateSystemAxis;
 import org.opengis.referencing.cs.RangeMeaning;
 import org.opengis.util.GenericName;
-import org.apache.sis.internal.util.Constants;
 import org.apache.sis.geometry.AbstractEnvelope;
 import org.apache.sis.geometry.GeneralDirectPosition;
+import org.apache.sis.metadata.iso.citation.Citations;
 import org.apache.sis.referencing.IdentifiedObjects;
 import org.apache.sis.util.iso.DefaultNameSpace;
 
 import static java.lang.StrictMath.*;
+import static org.apache.sis.internal.util.Constants.EPSG;
 
 
 /**
@@ -65,20 +65,53 @@ public strictfp class ReferencingAssert
     }
 
     /**
-     * Asserts that the string representation of the unique identifier of the 
given object is equals to the given
+     * Asserts that the given identifier has the expected code and the {@code 
"OGC"} code space.
+     * The authority is expected to be {@link Citations#OGC}. We expect the 
exact same authority
+     * instance because identifiers in OGC namespace are often hard-coded in 
SIS.
+     *
+     * @param expected The expected identifier code.
+     * @param actual   The identifier to verify.
+     *
+     * @since 0.6
+     */
+    public static void assertOgcIdentifierEquals(final String expected, final 
Identifier actual) {
+        assertNotNull(actual);
+        assertSame("Authority", Citations.OGC, actual.getAuthority());
+        Assert.assertIdentifierEquals(null, "OGC", "OGC", null, expected, 
actual);
+    }
+
+    /**
+     * Asserts that the given identifier has the expected code and the {@code 
"EPSG"} code space.
+     * The authority is expected to have the {@code "OGP"} title or alternate 
title.
+     *
+     * @param expected The expected identifier code.
+     * @param actual   The identifier to verify.
+     *
+     * @since 0.5
+     */
+    public static void assertEpsgIdentifierEquals(final String expected, final 
Identifier actual) {
+        assertNotNull(actual);
+        assertEquals("code",       expected, actual.getCode());
+        assertEquals("codeSpace",  EPSG,  actual.getCodeSpace());
+        assertEquals("authority",  "OGP", 
Citations.getIdentifier(actual.getAuthority()));
+        assertEquals("identifier", EPSG + DefaultNameSpace.DEFAULT_SEPARATOR + 
expected,
+                IdentifiedObjects.toString(actual));
+    }
+
+    /**
+     * Asserts that the string representation of the unique identifier in the 
given collection is equals to the given
      * EPSG code. As a special case if the given code is 0, then this method 
verifies that the given object has no
      * identifier.
      *
-     * @param code   The expected EPSG code, or {@code 0} if we expect no EPSG 
code.
-     * @param object The object for which to test the EPSG code.
+     * @param expected    The expected EPSG code, or {@code 0} if we expect no 
EPSG code.
+     * @param actual The set of identifiers in which to verify the EPSG code.
      */
-    public static void assertIdentifierEqualsEPSG(final int code, final 
IdentifiedObject object) {
-        final Set<Identifier> identifiers = object.getIdentifiers();
-        if (code == 0) {
-            assertTrue("identifiers.isEmpty()", identifiers.isEmpty());
+    public static void assertEpsgIdentifierEquals(final int expected, final 
Collection<? extends Identifier> actual) {
+        assertNotNull(actual);
+        if (expected == 0) {
+            assertTrue("identifiers.isEmpty()", actual.isEmpty());
         } else {
-            assertEquals("identifier", Constants.EPSG + 
DefaultNameSpace.DEFAULT_SEPARATOR + code,
-                    
IdentifiedObjects.toString(TestUtilities.getSingleton(identifiers)));
+            assertEpsgIdentifierEquals(String.valueOf(expected), 
TestUtilities.getSingleton(actual));
         }
     }
 

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=1667393&r1=1667392&r2=1667393&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] Tue Mar 17 20:25:34 2015
@@ -84,6 +84,7 @@ import org.junit.BeforeClass;
     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.MapProjectionTest.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