sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1684051 - in /sis/branches/JDK8/core: sis-metadata/src/main/java/org/apache/sis/internal/metadata/ sis-metadata/src/main/java/org/apache/sis/io/wkt/ sis-metadata/src/test/java/org/apache/sis/io/wkt/ sis-metadata/src/test/java/org/apache/si...
Date Sun, 07 Jun 2015 17:44:31 GMT
Author: desruisseaux
Date: Sun Jun  7 17:44:31 2015
New Revision: 1684051

URL: http://svn.apache.org/r1684051
Log:
WKT parsing: parser should parse axis abbreviation in the name, or infer axis abbreviation
by itself when the abbreviation was not specified in the name.

Added:
    sis/branches/JDK8/core/sis-metadata/src/test/java/org/apache/sis/io/wkt/WKTFormatTest.txt
      - copied, changed from r1683803, sis/branches/JDK8/core/sis-metadata/src/test/java/org/apache/sis/io/wkt/GeodeticObjectParserTest.txt
    sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/io/wkt/WKTFormatTest.java
      - copied, changed from r1683803, sis/branches/JDK8/core/sis-metadata/src/test/java/org/apache/sis/io/wkt/WKTFormatTest.java
Removed:
    sis/branches/JDK8/core/sis-metadata/src/test/java/org/apache/sis/io/wkt/GeodeticObjectParserTest.txt
    sis/branches/JDK8/core/sis-metadata/src/test/java/org/apache/sis/io/wkt/WKTFormatTest.java
Modified:
    sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/ReferencingServices.java
    sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/GeodeticObjectParser.java
    sis/branches/JDK8/core/sis-metadata/src/test/java/org/apache/sis/test/suite/MetadataTestSuite.java
    sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/AxisDirections.java
    sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/ServicesForMetadata.java
    sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultCoordinateSystemAxis.java
    sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/AxisDirectionsTest.java
    sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/io/wkt/GeodeticObjectParserTest.java
    sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/cs/HardCodedAxes.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/internal/metadata/ReferencingServices.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/ReferencingServices.java?rev=1684051&r1=1684050&r2=1684051&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/ReferencingServices.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/ReferencingServices.java
[UTF-8] Sun Jun  7 17:44:31 2015
@@ -25,6 +25,7 @@ import org.opengis.parameter.ParameterDe
 import org.opengis.referencing.IdentifiedObject;
 import org.opengis.referencing.crs.SingleCRS;
 import org.opengis.referencing.crs.DerivedCRS;
+import org.opengis.referencing.cs.AxisDirection;
 import org.opengis.referencing.cs.CartesianCS;
 import org.opengis.referencing.cs.CoordinateSystem;
 import org.opengis.referencing.cs.CoordinateSystemAxis;
@@ -378,6 +379,22 @@ public class ReferencingServices extends
         throw moduleNotFound();
     }
 
+    /**
+     * Suggests an abbreviation for the given axis direction. The unit of measurement may
be used
+     * for resolving some ambiguities like whether {@link AxisDirection#EAST} is for "x"
(Easting)
+     * or "λ" (Longitude). The axis name is used only in last resort.
+     *
+     * @param name      The axis name for which to suggest an abbreviation.
+     * @param direction The axis direction for which to suggest an abbreviation.
+     * @param unit      The axis unit of measurement, for disambiguation.
+     * @return A suggested abbreviation.
+     *
+     * @since 0.6
+     */
+    public String suggestAbbreviation(final String name, final AxisDirection direction, final
Unit<?> unit) {
+        throw moduleNotFound();
+    }
+
     /**
      * Creates the {@code TOWGS84} element during parsing of a WKT version 1. This is an
optional operation:
      * this method is allowed to return {@code null} if the "sis-referencing" module is not
in the classpath.

Modified: sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/GeodeticObjectParser.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/GeodeticObjectParser.java?rev=1684051&r1=1684050&r2=1684051&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/GeodeticObjectParser.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/GeodeticObjectParser.java
[UTF-8] Sun Jun  7 17:44:31 2015
@@ -55,6 +55,7 @@ import org.apache.sis.internal.metadata.
 import org.apache.sis.internal.metadata.ReferencingServices;
 import org.apache.sis.internal.util.LocalizedParseException;
 import org.apache.sis.internal.system.DefaultFactories;
+import org.apache.sis.util.CharSequences;
 import org.apache.sis.util.resources.Errors;
 import org.apache.sis.util.iso.Types;
 
@@ -405,11 +406,27 @@ final class GeodeticObjectParser extends
                 return null;
             }
         }
-        final String name = element.pullString("name");
+        String name = CharSequences.trimWhitespaces(element.pullString("name"));
         final Element orientation = element.pullVoidElement("orientation");
         final AxisDirection direction = Types.forCodeName(AxisDirection.class, orientation.keyword,
mandatory);
+        /*
+         * According ISO 19162, the abbreviation should be inserted between parenthesis in
the name.
+         * Example: "Easting (E)", "Longitude (L)". If we do not find an abbreviation, then
we will
+         * have to guess one since abbreviation is a mandatory part of axis.
+         */
+        final String abbreviation;
+        final int start, end = name.length() - 1;
+        if (end > 1 && name.charAt(end) == ')' && (start = name.lastIndexOf('(',
end-1)) >= 0) {
+            abbreviation = CharSequences.trimWhitespaces(name.substring(start + 1, end));
+            name = CharSequences.trimWhitespaces(name.substring(0, start));
+            if (name.isEmpty()) {
+                name = abbreviation;
+            }
+        } else {
+            abbreviation = referencing.suggestAbbreviation(name, direction, unit);
+        }
         try {
-            return csFactory.createCoordinateSystemAxis(parseAuthorityAndClose(element, name),
name, direction, unit);
+            return csFactory.createCoordinateSystemAxis(parseAuthorityAndClose(element, name),
abbreviation, direction, unit);
         } catch (FactoryException exception) {
             throw element.parseFailed(exception);
         }

Copied: sis/branches/JDK8/core/sis-metadata/src/test/java/org/apache/sis/io/wkt/WKTFormatTest.txt
(from r1683803, sis/branches/JDK8/core/sis-metadata/src/test/java/org/apache/sis/io/wkt/GeodeticObjectParserTest.txt)
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-metadata/src/test/java/org/apache/sis/io/wkt/WKTFormatTest.txt?p2=sis/branches/JDK8/core/sis-metadata/src/test/java/org/apache/sis/io/wkt/WKTFormatTest.txt&p1=sis/branches/JDK8/core/sis-metadata/src/test/java/org/apache/sis/io/wkt/GeodeticObjectParserTest.txt&r1=1683803&r2=1684051&rev=1684051&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-metadata/src/test/java/org/apache/sis/io/wkt/GeodeticObjectParserTest.txt
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-metadata/src/test/java/org/apache/sis/io/wkt/WKTFormatTest.txt
[UTF-8] Sun Jun  7 17:44:31 2015
@@ -1,3 +1,4 @@
-GeodeticObjectParser and MathTransformParser can not be tested here,
+WKTFormat and some of its dependencies (GeodeticObjectParser and
+MathTransformParser) can not be tested in "sis-metadata" module,
 because they need the "sis-referencing" module at execution time.
 Those test classes are added by the "sis-referencing" module.

Modified: sis/branches/JDK8/core/sis-metadata/src/test/java/org/apache/sis/test/suite/MetadataTestSuite.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-metadata/src/test/java/org/apache/sis/test/suite/MetadataTestSuite.java?rev=1684051&r1=1684050&r2=1684051&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-metadata/src/test/java/org/apache/sis/test/suite/MetadataTestSuite.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-metadata/src/test/java/org/apache/sis/test/suite/MetadataTestSuite.java
[UTF-8] Sun Jun  7 17:44:31 2015
@@ -98,8 +98,7 @@ import org.junit.BeforeClass;
     org.apache.sis.io.wkt.CharEncodingTest.class,
     org.apache.sis.io.wkt.ColorsTest.class,
     org.apache.sis.io.wkt.FormatterTest.class,
-    org.apache.sis.io.wkt.ElementTest.class,
-    org.apache.sis.io.wkt.WKTFormatTest.class
+    org.apache.sis.io.wkt.ElementTest.class
 })
 public final strictfp class MetadataTestSuite extends TestSuite {
     /**

Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/AxisDirections.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/AxisDirections.java?rev=1684051&r1=1684050&r2=1684051&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/AxisDirections.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/AxisDirections.java
[UTF-8] Sun Jun  7 17:44:31 2015
@@ -16,6 +16,7 @@
  */
 package org.apache.sis.internal.referencing;
 
+import javax.measure.unit.Unit;
 import org.opengis.referencing.cs.AxisDirection;
 import org.opengis.referencing.cs.CoordinateSystem;
 import org.opengis.referencing.cs.CoordinateSystemAxis;
@@ -23,6 +24,7 @@ import org.apache.sis.internal.util.Util
 import org.apache.sis.util.Characters;
 import org.apache.sis.util.Static;
 import org.apache.sis.util.iso.Types;
+import org.apache.sis.measure.Units;
 
 import static org.opengis.referencing.cs.AxisDirection.*;
 import static org.apache.sis.util.CharSequences.*;
@@ -516,6 +518,74 @@ public final class AxisDirections extend
     }
 
     /**
+     * Returns {@code true} if the given name starts with the given keyword, ignoring case.
+     */
+    private static boolean startsWith(final String name, final String keyword) {
+        return name.regionMatches(true, 0, keyword, 0, keyword.length());
+    }
+
+    /**
+     * Suggests an abbreviation for the given axis direction. The unit of measurement may
be used
+     * for resolving some ambiguities like whether {@link AxisDirection#EAST} is for "x"
(Easting)
+     * or "λ" (Longitude). The axis name is used only in last resort.
+     *
+     * @param name      The axis name for which to suggest an abbreviation.
+     * @param direction The axis direction for which to suggest an abbreviation.
+     * @param unit      The axis unit of measurement, for disambiguation.
+     * @return A suggested abbreviation.
+     *
+     * @since 0.6
+     */
+    public static String suggestAbbreviation(final String name, final AxisDirection direction,
final Unit<?> unit) {
+        if (isCompass(direction)) {
+            /*
+             * NORTH, EAST, SOUTH, WEST and all intercardinal directions (SOUTH_SOUTH_WEST,
etc.):
+             * we will use the acronym (e.g. "SE" for SOUTH_EAST), unless the axis is likely
to be
+             * a longitude or latitude axis. We detect those later cases by the unit of measurement.
+             */
+            if (!isIntercardinal(direction) && Units.isAngular(unit)) {
+                if (startsWith(name, "Spherical")) {
+                    return NORTH.equals(absolute(direction)) ? "φ′" : "θ";
+                } else {
+                    return NORTH.equals(absolute(direction)) ? "φ" : "λ";
+                }
+            }
+        } else {
+            /*
+             * All cases other than NORTH, SOUTH, etc. The most common direction is UP, in
which case the
+             * abbreviation shall be "H" for Gravity-related height and "h" for ellipsoidal
height. Those
+             * two names are specified by ISO 19111, but we will use "Gravity" as a criterion
because we
+             * use "h" as the fallback for unknown vertical axis.
+             */
+            if (UP.equals(direction)) {
+                return startsWith(name, "Gravity") ? "H" : startsWith(name, "Geocentric")
? "r": "h";
+            } else if (DOWN.equals(direction)) {
+                return "D"; // "Depth"
+            } else if (isGeocentric(direction)) {
+                // For GEOCENTRIC_X, GEOCENTRIC_Y or GEOCENTRIC_Z, just take the last letter.
+                final String dir = direction.name();
+                return dir.substring(dir.length() - 1).trim();
+            }
+            final AxisDirection a = absolute(direction);
+            if (FUTURE.equals(a)) {
+                return "t";
+            } else if (COLUMN_POSITIVE.equals(a)) {
+                return "i";
+            } else if (ROW_POSITIVE.equals(a)) {
+                return "j";
+            } else if (DISPLAY_RIGHT.equals(a)) {
+                return "x";
+            } else if (DISPLAY_UP.equals(a)) {
+                return "y";
+            } else if (OTHER.equals(a)) {
+                return "z";  // Arbitrary abbreviation, may change in any future SIS version.
+            }
+        }
+        final String id = direction.identifier();   // UML identifier, or null if none.
+        return camelCaseToAcronym(id != null ? id : direction.name()).toString().intern();
+    }
+
+    /**
      * Builds a coordinate system name from the given array of axes.
      * This method expects a {@code StringBuilder} pre-filled with the coordinate system
name.
      * The axis directions and abbreviations will be appended after the CS name.

Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/ServicesForMetadata.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/ServicesForMetadata.java?rev=1684051&r1=1684050&r2=1684051&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/ServicesForMetadata.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/ServicesForMetadata.java
[UTF-8] Sun Jun  7 17:44:31 2015
@@ -34,6 +34,7 @@ import org.opengis.referencing.crs.Tempo
 import org.opengis.referencing.crs.VerticalCRS;
 import org.opengis.referencing.crs.GeographicCRS;
 import org.opengis.referencing.crs.CoordinateReferenceSystem;
+import org.opengis.referencing.cs.AxisDirection;
 import org.opengis.referencing.cs.CartesianCS;
 import org.opengis.referencing.cs.CoordinateSystem;
 import org.opengis.referencing.cs.CoordinateSystemAxis;
@@ -536,6 +537,23 @@ public final class ServicesForMetadata e
     }
 
     /**
+     * Suggests an abbreviation for the given axis direction. The unit of measurement may
be used
+     * for resolving some ambiguities like whether {@link AxisDirection#EAST} is for "x"
(Easting)
+     * or "λ" (Longitude). The axis name is used only in last resort.
+     *
+     * @param name      The axis name for which to suggest an abbreviation.
+     * @param direction The axis direction for which to suggest an abbreviation.
+     * @param unit      The axis unit of measurement, for disambiguation.
+     * @return A suggested abbreviation.
+     *
+     * @since 0.6
+     */
+    @Override
+    public String suggestAbbreviation(final String name, final AxisDirection direction, final
Unit<?> unit) {
+        return AxisDirections.suggestAbbreviation(name, direction, unit);
+    }
+
+    /**
      * Creates the {@code TOWGS84} element during parsing of a WKT version 1.
      *
      * @param  values The 7 Bursa-Wolf parameter values.

Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultCoordinateSystemAxis.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultCoordinateSystemAxis.java?rev=1684051&r1=1684050&r2=1684051&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultCoordinateSystemAxis.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultCoordinateSystemAxis.java
[UTF-8] Sun Jun  7 17:44:31 2015
@@ -526,7 +526,9 @@ public class DefaultCoordinateSystemAxis
 
     /**
      * Returns the meaning of axis value range specified by the {@linkplain #getMinimumValue()
minimum}
-     * and {@linkplain #getMaximumValue() maximum} values.
+     * and {@linkplain #getMaximumValue() maximum} values. If there is no minimum and maximum
values
+     * (i.e. if those values are {@linkplain Double#NEGATIVE_INFINITY negative infinity}
and
+     * {@linkplain Double#POSITIVE_INFINITY positive infinity} respectively), then this method
returns {@code null}.
      *
      * @return The meaning of axis value range, or {@code null} if unspecified.
      */

Modified: sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/AxisDirectionsTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/AxisDirectionsTest.java?rev=1684051&r1=1684050&r2=1684051&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/AxisDirectionsTest.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/AxisDirectionsTest.java
[UTF-8] Sun Jun  7 17:44:31 2015
@@ -16,6 +16,9 @@
  */
 package org.apache.sis.internal.referencing;
 
+import javax.measure.unit.SI;
+import javax.measure.unit.NonSI;
+import javax.measure.unit.Unit;
 import org.opengis.referencing.cs.AxisDirection;
 import org.opengis.referencing.cs.CoordinateSystem;
 import org.opengis.referencing.cs.CoordinateSystemAxis;
@@ -361,6 +364,40 @@ public final strictfp class AxisDirectio
     }
 
     /**
+     * Tests {@link AxisDirections#suggestAbbreviation(String, AxisDirection, Unit)}.
+     *
+     * @since 0.6
+     */
+    @Test
+    public void testSuggestAbbreviation() {
+        assertEquals("λ",   AxisDirections.suggestAbbreviation("Geodetic longitude",   
 EAST,          NonSI.DEGREE_ANGLE));
+        assertEquals("φ",   AxisDirections.suggestAbbreviation("Geodetic latitude",    
 NORTH,         NonSI.DEGREE_ANGLE));
+        assertEquals("θ",   AxisDirections.suggestAbbreviation("Spherical longitude",  
 EAST,          NonSI.DEGREE_ANGLE));
+        assertEquals("φ′",  AxisDirections.suggestAbbreviation("Spherical latitude", 
   NORTH,         NonSI.DEGREE_ANGLE));
+        assertEquals("h",   AxisDirections.suggestAbbreviation("Ellipsoidal height",    
UP,               SI.METRE));
+        assertEquals("H",   AxisDirections.suggestAbbreviation("Gravity-related height",
UP,               SI.METRE));
+        assertEquals("r",   AxisDirections.suggestAbbreviation("Geocentric radius",     
UP,               SI.METRE));
+        assertEquals("X",   AxisDirections.suggestAbbreviation("not needed",            
GEOCENTRIC_X,     SI.METRE));
+        assertEquals("Y",   AxisDirections.suggestAbbreviation("not needed",            
GEOCENTRIC_Y,     SI.METRE));
+        assertEquals("Z",   AxisDirections.suggestAbbreviation("not needed",            
GEOCENTRIC_Z,     SI.METRE));
+        assertEquals("D",   AxisDirections.suggestAbbreviation("not needed",            
DOWN,             SI.METRE));
+        assertEquals("t",   AxisDirections.suggestAbbreviation("not needed",            
FUTURE,        NonSI.DAY));
+        assertEquals("i",   AxisDirections.suggestAbbreviation("not needed",            
COLUMN_NEGATIVE,  Unit.ONE));
+        assertEquals("j",   AxisDirections.suggestAbbreviation("not needed",            
ROW_NEGATIVE,     Unit.ONE));
+        assertEquals("x",   AxisDirections.suggestAbbreviation("not needed",            
DISPLAY_RIGHT,    Unit.ONE));
+        assertEquals("y",   AxisDirections.suggestAbbreviation("not needed",            
DISPLAY_DOWN,     Unit.ONE));
+        assertEquals("N",   AxisDirections.suggestAbbreviation("not needed",            
NORTH,            SI.METRE));
+        assertEquals("S",   AxisDirections.suggestAbbreviation("not needed",            
SOUTH,            SI.METRE));
+        assertEquals("E",   AxisDirections.suggestAbbreviation("not needed",            
EAST,             SI.METRE));
+        assertEquals("W",   AxisDirections.suggestAbbreviation("not needed",            
WEST,             SI.METRE));
+        assertEquals("NE",  AxisDirections.suggestAbbreviation("not needed",            
NORTH_EAST,       SI.METRE));
+        assertEquals("NW",  AxisDirections.suggestAbbreviation("not needed",            
NORTH_WEST,       SI.METRE));
+        assertEquals("SE",  AxisDirections.suggestAbbreviation("not needed",            
SOUTH_EAST,       SI.METRE));
+        assertEquals("SW",  AxisDirections.suggestAbbreviation("not needed",            
SOUTH_WEST,       SI.METRE));
+//      assertEquals("SSE", AxisDirections.suggestAbbreviation("not needed",            
SOUTH_SOUTH_EAST, SI.METRE));
+    }
+
+    /**
      * Tests {@link AxisDirections#appendTo(StringBuilder, CoordinateSystemAxis[])}.
      *
      * @since 0.6

Modified: sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/io/wkt/GeodeticObjectParserTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/io/wkt/GeodeticObjectParserTest.java?rev=1684051&r1=1684050&r2=1684051&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/io/wkt/GeodeticObjectParserTest.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/io/wkt/GeodeticObjectParserTest.java
[UTF-8] Sun Jun  7 17:44:31 2015
@@ -20,7 +20,11 @@ import java.util.Date;
 import java.util.Iterator;
 import java.text.ParsePosition;
 import java.text.ParseException;
+import javax.measure.unit.SI;
+import javax.measure.unit.NonSI;
+import javax.measure.unit.Unit;
 import org.opengis.referencing.IdentifiedObject;
+import org.opengis.referencing.cs.*;
 import org.opengis.referencing.crs.*;
 import org.opengis.referencing.datum.*;
 import org.apache.sis.test.DependsOnMethod;
@@ -28,7 +32,7 @@ import org.apache.sis.test.DependsOn;
 import org.apache.sis.test.TestCase;
 import org.junit.Test;
 
-import static org.junit.Assert.*;
+import static org.apache.sis.test.ReferencingAssert.*;
 
 
 /**
@@ -39,7 +43,15 @@ import static org.junit.Assert.*;
  * @version 0.6
  * @module
  */
-@DependsOn(MathTransformParserTest.class)
+@DependsOn({
+    MathTransformParserTest.class,
+    org.apache.sis.referencing.crs.DefaultGeocentricCRSTest.class,
+    org.apache.sis.referencing.crs.DefaultGeographicCRSTest.class,
+    org.apache.sis.referencing.crs.DefaultVerticalCRSTest.class,
+    org.apache.sis.referencing.crs.DefaultTemporalCRSTest.class,
+    org.apache.sis.referencing.crs.DefaultCompoundCRSTest.class,
+    org.apache.sis.internal.referencing.AxisDirectionsTest.class
+})
 public final strictfp class GeodeticObjectParserTest extends TestCase {
     /**
      * The parser to use for the test.
@@ -51,7 +63,7 @@ public final strictfp class GeodeticObje
      *
      * @throws ParseException if an error occurred during the parsing.
      */
-    private Object parse(final String text) throws ParseException {
+    private <T> T parse(final Class<T> type, final String text) throws ParseException
{
         if (parser == null) {
             parser = new GeodeticObjectParser();
         }
@@ -59,15 +71,83 @@ public final strictfp class GeodeticObje
         final Object obj = parser.parseObject(text, position);
         assertEquals("errorIndex", -1, position.getErrorIndex());
         assertEquals("index", text.length(), position.getIndex());
-        return obj;
+        assertInstanceOf("GeodeticObjectParser.parseObject", type, obj);
+        return type.cast(obj);
     }
 
     /**
-     * Asserts that the name of the given object is equals to the given string.
+     * Asserts that the name and (optionally) the EPSG identifier of the given object
+     * are equal to the given strings.
+     *
+     * @param name The expected name.
+     * @param epsg The expected EPSG identifier, or {@code 0} if the object shall have no
identifier.
      */
-    private static void assertNameEquals(final String expected, final IdentifiedObject object)
{
+    static void assertNameAndIdentifierEqual(final String name, final int epsg, final IdentifiedObject
object) {
         final String message = object.getClass().getSimpleName();
-        assertEquals(message, expected, object.getName().getCode());
+        assertEquals(message, name, object.getName().getCode());
+        assertEpsgIdentifierEquals(epsg, object.getIdentifiers());
+    }
+
+    /**
+     * Asserts the given axis is a longitude axis of the given name.
+     */
+    private static void assertLongitudeAxisEquals(final String name, final CoordinateSystemAxis
axis) {
+        assertAxisEquals(name, "λ", AxisDirection.EAST, -180, +180, NonSI.DEGREE_ANGLE,
RangeMeaning.WRAPAROUND, axis);
+    }
+
+    /**
+     * Asserts the given axis is a latitude axis of the given name.
+     */
+    private static void assertLatitudeAxisEquals(final String name, final CoordinateSystemAxis
axis) {
+        assertAxisEquals(name, "φ", AxisDirection.NORTH, -90, +90, NonSI.DEGREE_ANGLE, RangeMeaning.EXACT,
axis);
+    }
+
+    /**
+     * Asserts the given axis is an axis of the given name without minimum and maximum values.
+     */
+    private static void assertUnboundedAxisEquals(final String name, final String abbreviation,
+            final AxisDirection direction, final Unit<?> unit, final CoordinateSystemAxis
axis)
+    {
+        assertAxisEquals(name, abbreviation, direction, Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY,
unit, null, axis);
+    }
+
+    /**
+     * Tests the parsing of a geocentric CRS from a WKT 1 string. The parser
+     * shall replace the OGC 01-009 axis directions (OTHER, EAST, NORTH) by
+     * ISO 19111 axis directions (Geocentric X, Geocentric Y, Geocentric Z).
+     *
+     * @throws ParseException if the parsing failed.
+     */
+    @Test
+    public void testGeocentricCRS() throws ParseException {
+        final GeocentricCRS crs = parse(GeocentricCRS.class,
+                "GEOCCS[“Geocentric”,\n" +
+                "  DATUM[“World Geodetic System 1984”,\n" +
+                "    SPHEROID[“WGS84”, 6378137.0, 298.257223563, AUTHORITY[“EPSG”,
“7030”]],\n" +
+                "    AUTHORITY[“EPSG”, “6326”]],\n" +
+                "    PRIMEM[“Greenwich”, 0.0, AUTHORITY[“EPSG”, “8901”]],\n"
+
+                "  UNIT[“metre”, 1.0],\n" +
+                "  AXIS[“X”, OTHER],\n" +
+                "  AXIS[“Y”, EAST],\n" +
+                "  AXIS[“Z”, NORTH]]");
+
+        assertNameAndIdentifierEqual("Geocentric", 0, crs);
+
+        final GeodeticDatum datum = crs.getDatum();
+        assertNameAndIdentifierEqual("World Geodetic System 1984", 6326, datum);
+        assertNameAndIdentifierEqual("Greenwich", 8901, datum.getPrimeMeridian());
+
+        final Ellipsoid ellipsoid = datum.getEllipsoid();
+        assertNameAndIdentifierEqual("WGS84", 7030, ellipsoid);
+        assertEquals("semiMajor", 6378137, ellipsoid.getSemiMajorAxis(), STRICT);
+        assertEquals("inverseFlattening", 298.257223563, ellipsoid.getInverseFlattening(),
STRICT);
+
+        // Verify that the OGC 01-009 axes have been relaced by ISO 19111 axes.
+        final CartesianCS cs = (CartesianCS) crs.getCoordinateSystem();
+        assertEquals("dimension", 3, cs.getDimension());
+        assertUnboundedAxisEquals("Geocentric X", "X", AxisDirection.GEOCENTRIC_X, SI.METRE,
cs.getAxis(0));
+        assertUnboundedAxisEquals("Geocentric Y", "Y", AxisDirection.GEOCENTRIC_Y, SI.METRE,
cs.getAxis(1));
+        assertUnboundedAxisEquals("Geocentric Z", "Z", AxisDirection.GEOCENTRIC_Z, SI.METRE,
cs.getAxis(2));
     }
 
     /**
@@ -77,7 +157,7 @@ public final strictfp class GeodeticObje
      */
     @Test
     public void testCompoundCRS() throws ParseException {
-        final CompoundCRS crs = (CompoundCRS) parse(
+        final CompoundCRS crs = parse(CompoundCRS.class,
                 "COMPD_CS[“WGS 84 + height + time”,\n" +
                 "  GEOGCS[“WGS 84”,\n" +
                 "    DATUM[“World Geodetic System 1984”,\n" +
@@ -96,55 +176,41 @@ public final strictfp class GeodeticObje
                 "    Axis[“Time”, FUTURE]]]");
 
         // CompoundCRS parent
-        assertNameEquals("WGS 84 + height + time", crs);
+        assertNameAndIdentifierEqual("WGS 84 + height + time", 0, crs);
         final Iterator<CoordinateReferenceSystem> components = crs.getComponents().iterator();
 
         // GeographicCRS child
         final GeographicCRS geoCRS    = (GeographicCRS) components.next();
         final GeodeticDatum geoDatum  = geoCRS.getDatum();
         final Ellipsoid     ellipsoid = geoDatum.getEllipsoid();
-        assertNameEquals("WGS 84", geoCRS);
-        assertNameEquals("World Geodetic System 1984", geoDatum);
-        assertNameEquals("WGS84", ellipsoid);
-        assertNameEquals("Greenwich", geoDatum.getPrimeMeridian());
+        assertNameAndIdentifierEqual("WGS 84", 0, geoCRS);
+        assertNameAndIdentifierEqual("World Geodetic System 1984", 0, geoDatum);
+        assertNameAndIdentifierEqual("WGS84", 0, ellipsoid);
+        assertNameAndIdentifierEqual("Greenwich", 0, geoDatum.getPrimeMeridian());
         assertEquals("semiMajor", 6378137, ellipsoid.getSemiMajorAxis(), STRICT);
         assertEquals("inverseFlattening", 298.257223563, ellipsoid.getInverseFlattening(),
STRICT);
 
         // VerticalCRS child
         final VerticalCRS vertCRS = (VerticalCRS) components.next();
-        assertNameEquals("Gravity-related height", vertCRS);
-        assertNameEquals("Mean Sea Level", vertCRS.getDatum());
+        assertNameAndIdentifierEqual("Gravity-related height", 0, vertCRS);
+        assertNameAndIdentifierEqual("Mean Sea Level", 0, vertCRS.getDatum());
 
         // TemporalCRS child
         final TemporalCRS   timeCRS   = (TemporalCRS) components.next();
         final TemporalDatum timeDatum = timeCRS.getDatum();
-        assertNameEquals("Time", timeCRS);
-        assertNameEquals("Modified Julian", timeDatum);
+        assertNameAndIdentifierEqual("Time", 0, timeCRS);
+        assertNameAndIdentifierEqual("Modified Julian", 0, timeDatum);
         assertEquals("epoch", new Date(-40587 * (24*60*60*1000L)), timeDatum.getOrigin());
 
         // No more CRS.
         assertFalse(components.hasNext());
-    }
-
-    /**
-     * Tests integration in {@link WKTFormat#parse(CharSequence, ParsePosition)}.
-     * This method tests only a simple WKT because it is not the purpose of this
-     * method to test the parser itself. We only want to tests its integration in
-     * the {@link WKTFormat} class.
-     *
-     * @throws ParseException if the parsing failed.
-     */
-    @Test
-    @DependsOnMethod("testCompoundCRS")
-    public void testWKTFormat() throws ParseException {
-        final WKTFormat format = new WKTFormat(null, null);
-        final VerticalCRS crs = (VerticalCRS) format.parseObject(
-                "VERT_CS[“Gravity-related height”,\n" +
-                "  VERT_DATUM[“Mean Sea Level”, 2005],\n" +
-                "  UNIT[“metre”, 1],\n" +
-                "  AXIS[“Gravity-related height”, UP]]");
 
-        assertNameEquals("Gravity-related height", crs);
-        assertNameEquals("Mean Sea Level", crs.getDatum());
+        // Axes: we verify only the CompoundCRS ones, which should include all others.
+        final CoordinateSystem cs = crs.getCoordinateSystem();
+        assertEquals("dimension", 4, cs.getDimension());
+        assertLongitudeAxisEquals("Longitude", cs.getAxis(0));
+        assertLatitudeAxisEquals ("Latitude", cs.getAxis(1));
+        assertUnboundedAxisEquals("Gravity-related height", "H", AxisDirection.UP, SI.METRE,
cs.getAxis(2));
+        assertUnboundedAxisEquals("Time", "t", AxisDirection.FUTURE, NonSI.DAY, cs.getAxis(3));
     }
 }

Copied: sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/io/wkt/WKTFormatTest.java
(from r1683803, sis/branches/JDK8/core/sis-metadata/src/test/java/org/apache/sis/io/wkt/WKTFormatTest.java)
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/io/wkt/WKTFormatTest.java?p2=sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/io/wkt/WKTFormatTest.java&p1=sis/branches/JDK8/core/sis-metadata/src/test/java/org/apache/sis/io/wkt/WKTFormatTest.java&r1=1683803&r2=1684051&rev=1684051&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-metadata/src/test/java/org/apache/sis/io/wkt/WKTFormatTest.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/io/wkt/WKTFormatTest.java
[UTF-8] Sun Jun  7 17:44:31 2015
@@ -16,6 +16,9 @@
  */
 package org.apache.sis.io.wkt;
 
+import java.text.ParseException;
+import org.opengis.referencing.crs.VerticalCRS;
+import org.apache.sis.test.DependsOn;
 import org.apache.sis.test.TestCase;
 import org.junit.Test;
 
@@ -23,15 +26,14 @@ import static org.junit.Assert.*;
 
 
 /**
- * Tests {@link WKTFormat}. This class can test only formatting operations.
- * WKT parsing operations require the {@code "sis-referencing"} module, so
- * they will be tested in {@link GeodeticObjectParserTest}.
+ * Tests {@link WKTFormat}.
  *
  * @author  Martin Desruisseaux (Geomatys)
  * @since   0.5
- * @version 0.5
+ * @version 0.6
  * @module
  */
+@DependsOn(GeodeticObjectParserTest.class)
 public final strictfp class WKTFormatTest extends TestCase {
     /**
      * Verifies the condition documented in {@link WKTFormat#SHORT_DATE_PATTERN} javadoc.
@@ -40,4 +42,25 @@ public final strictfp class WKTFormatTes
     public void testDatePatterns() {
         assertTrue(WKTFormat.DATE_PATTERN.startsWith(WKTFormat.SHORT_DATE_PATTERN));
     }
+
+    /**
+     * Tests integration in {@link WKTFormat#parse(CharSequence, ParsePosition)}.
+     * This method tests only a simple WKT because it is not the purpose of this
+     * method to test the parser itself. We only want to tests its integration in
+     * the {@link WKTFormat} class.
+     *
+     * @throws ParseException if the parsing failed.
+     */
+    @Test
+    public void testParse() throws ParseException {
+        final WKTFormat format = new WKTFormat(null, null);
+        final VerticalCRS crs = (VerticalCRS) format.parseObject(
+                "VERT_CS[“Gravity-related height”,\n" +
+                "  VERT_DATUM[“Mean Sea Level”, 2005],\n" +
+                "  UNIT[“metre”, 1],\n" +
+                "  AXIS[“Gravity-related height”, UP]]");
+
+        GeodeticObjectParserTest.assertNameAndIdentifierEqual("Gravity-related height", 0,
crs);
+        GeodeticObjectParserTest.assertNameAndIdentifierEqual("Mean Sea Level", 0, crs.getDatum());
+    }
 }

Modified: sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/cs/HardCodedAxes.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/cs/HardCodedAxes.java?rev=1684051&r1=1684050&r2=1684051&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/cs/HardCodedAxes.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/cs/HardCodedAxes.java
[UTF-8] Sun Jun  7 17:44:31 2015
@@ -404,7 +404,7 @@ public final strictfp class HardCodedAxe
      * and the unit is dimensionless. This constant is sometime used as a placeholder
      * for axes that were not properly defined.
      */
-    public static final DefaultCoordinateSystemAxis UNDEFINED = create("Undefined", "?",
+    public static final DefaultCoordinateSystemAxis UNDEFINED = create("Undefined", "z",
             AxisDirection.OTHER, Unit.ONE, Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY,
null);
 
     /**

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=1684051&r1=1684050&r2=1684051&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] Sun Jun  7 17:44:31 2015
@@ -142,6 +142,7 @@ import org.junit.BeforeClass;
 
     org.apache.sis.io.wkt.MathTransformParserTest.class,
     org.apache.sis.io.wkt.GeodeticObjectParserTest.class,
+    org.apache.sis.io.wkt.WKTFormatTest.class,
 
     org.apache.sis.geometry.AbstractDirectPositionTest.class,
     org.apache.sis.geometry.GeneralDirectPositionTest.class,



Mime
View raw message