sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1541711 - in /sis/branches/JDK7/core/sis-referencing/src: main/java/org/apache/sis/internal/referencing/ test/java/org/apache/sis/referencing/datum/ test/java/org/apache/sis/test/suite/
Date Wed, 13 Nov 2013 21:02:15 GMT
Author: desruisseaux
Date: Wed Nov 13 21:02:15 2013
New Revision: 1541711

URL: http://svn.apache.org/r1541711
Log:
Added DefaultVerticalDatumTest.

Added:
    sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/datum/DefaultVerticalDatumTest.java
  (with props)
Modified:
    sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/VerticalDatumTypes.java
    sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/test/suite/ReferencingTestSuite.java

Modified: sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/VerticalDatumTypes.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/VerticalDatumTypes.java?rev=1541711&r1=1541710&r2=1541711&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/VerticalDatumTypes.java
[UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/VerticalDatumTypes.java
[UTF-8] Wed Nov 13 21:02:15 2013
@@ -16,8 +16,8 @@
  */
 package org.apache.sis.internal.referencing;
 
-import org.opengis.referencing.datum.Datum;
 import org.opengis.util.CodeList;
+import org.opengis.referencing.datum.VerticalDatum;
 import org.opengis.referencing.datum.VerticalDatumType;
 import org.apache.sis.referencing.IdentifiedObjects;
 import org.apache.sis.util.StringBuilders;
@@ -114,16 +114,16 @@ public final class VerticalDatumTypes im
      * Guesses the type of the given datum using its name or identifiers. This is sometime
needed
      * after XML unmarshalling, since GML 3.2 does not contain any attribute for the datum
type.
      *
-     * <p>This method uses heuristic rules and may be changed in any future SIS version.
If the type can not be
-     * determined, default on the ellipsoidal type since it will usually implies no additional
calculation.</p>
+     * <p>This method uses heuristic rules and may be changed in any future SIS version.
+     * If the type can not be determined, default on {@link VerticalDatumType#OTHER_SURFACE}.</p>
      *
      * @param  datum The datum for which to guess a type.
-     * @return A datum type, or {@link #ELLIPSOIDAL} if none can be guessed.
+     * @return A datum type, or {@link VerticalDatumType#OTHER_SURFACE} if none can be guessed.
      */
-    public static VerticalDatumType guess(final Datum datum) {
+    public static VerticalDatumType guess(final VerticalDatum datum) {
         final VerticalDatumType type = CodeList.valueOf(VerticalDatumType.class,
                 new VerticalDatumTypes(IdentifiedObjects.getName(datum, null)));
-        return (type != null) ? type : ELLIPSOIDAL;
+        return (type != null) ? type : VerticalDatumType.OTHER_SURFACE;
     }
 
     /**
@@ -144,7 +144,7 @@ public final class VerticalDatumTypes im
         datum = new StringBuilder(length);
         for (int i=0; i<length;) {
             final int c = name.codePointAt(i);
-            datum.appendCodePoint(Character.toUpperCase(i));
+            datum.appendCodePoint(Character.toUpperCase(c));
             i += Character.charCount(c);
         }
         StringBuilders.toASCII(datum);

Added: sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/datum/DefaultVerticalDatumTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/datum/DefaultVerticalDatumTest.java?rev=1541711&view=auto
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/datum/DefaultVerticalDatumTest.java
(added)
+++ sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/datum/DefaultVerticalDatumTest.java
[UTF-8] Wed Nov 13 21:02:15 2013
@@ -0,0 +1,67 @@
+/*
+ *    Geotoolkit.org - An Open Source Java GIS Toolkit
+ *    http://www.geotoolkit.org
+ *
+ *    (C) 2011-2012, Open Source Geospatial Foundation (OSGeo)
+ *    (C) 2011-2012, Geomatys
+ *
+ *    This library is free software; you can redistribute it and/or
+ *    modify it under the terms of the GNU Lesser General Public
+ *    License as published by the Free Software Foundation;
+ *    version 2.1 of the License.
+ *
+ *    This library is distributed in the hope that it will be useful,
+ *    but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ *    Lesser General Public License for more details.
+ */
+package org.apache.sis.referencing.datum;
+
+import java.lang.reflect.Field;
+import org.opengis.referencing.datum.VerticalDatumType;
+import org.apache.sis.internal.referencing.VerticalDatumTypes;
+import org.apache.sis.test.DependsOn;
+import org.apache.sis.test.TestCase;
+import org.junit.Test;
+
+import static org.junit.Assert.*;
+import static java.util.Collections.singletonMap;
+
+
+/**
+ * Tests the {@link DefaultVerticalDatum} class.
+ *
+ * @author  Martin Desruisseaux (Geomatys)
+ * @since   0.4 (derived from geotk-3.20)
+ * @version 0.4
+ * @module
+ */
+@DependsOn(org.apache.sis.internal.referencing.VerticalDatumTypesTest.class)
+public final strictfp class DefaultVerticalDatumTest extends TestCase {
+    /**
+     * Tests the {@link DefaultVerticalDatum#getVerticalDatumType()} method in a state
+     * simulating unmarshalling of GML 3.2 document.
+     *
+     * @throws NoSuchFieldException   Should never happen.
+     * @throws IllegalAccessException Should never happen.
+     */
+    @Test
+    public void testAfterUnmarshal() throws NoSuchFieldException, IllegalAccessException
{
+        final Field typeField = DefaultVerticalDatum.class.getDeclaredField("type");
+        typeField.setAccessible(true);
+        assertEquals(VerticalDatumType .GEOIDAL,       typeForName(typeField, "Geoidal height"));
+        assertEquals(VerticalDatumType .DEPTH,         typeForName(typeField, "Some depth
measurement"));
+        assertEquals(VerticalDatumTypes.ELLIPSOIDAL,   typeForName(typeField, "Ellipsoidal
height"));
+        assertEquals(VerticalDatumType .OTHER_SURFACE, typeForName(typeField, "NotADepth"));
+    }
+
+    /**
+     * Returns the vertical datum type inferred by {@link DefaultVerticalDatum} for the given
name.
+     */
+    private static VerticalDatumType typeForName(final Field typeField, final String name)
throws IllegalAccessException {
+        final DefaultVerticalDatum datum = new DefaultVerticalDatum(
+                singletonMap(DefaultVerticalDatum.NAME_KEY, name), VerticalDatumType.OTHER_SURFACE);
+        typeField.set(datum, null);
+        return datum.getVerticalDatumType();
+    }
+}

Propchange: sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/datum/DefaultVerticalDatumTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/datum/DefaultVerticalDatumTest.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain;charset=UTF-8

Modified: sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/test/suite/ReferencingTestSuite.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/test/suite/ReferencingTestSuite.java?rev=1541711&r1=1541710&r2=1541711&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/test/suite/ReferencingTestSuite.java
[UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/test/suite/ReferencingTestSuite.java
[UTF-8] Wed Nov 13 21:02:15 2013
@@ -52,6 +52,7 @@ import org.junit.BeforeClass;
     org.apache.sis.referencing.datum.BursaWolfParametersTest.class,
     org.apache.sis.referencing.datum.TimeDependentBWPTest.class,
     org.apache.sis.referencing.datum.DefaultEllipsoidTest.class,
+    org.apache.sis.referencing.datum.DefaultVerticalDatumTest.class,
     org.apache.sis.referencing.GeodeticObjectsTest.class,
 
     org.apache.sis.geometry.AbstractDirectPositionTest.class,



Mime
View raw message