sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1544737 - in /sis/branches/JDK7/core: sis-referencing/src/main/java/org/apache/sis/referencing/cs/ sis-utility/src/main/java/org/apache/sis/util/resources/
Date Sat, 23 Nov 2013 02:36:41 GMT
Author: desruisseaux
Date: Sat Nov 23 02:36:41 2013
New Revision: 1544737

URL: http://svn.apache.org/r1544737
Log:
Ported the method for parsing a String to an AxisDirection.

Modified:
    sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/CoordinateSystems.java
    sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DirectionAlongMeridian.java
    sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors.java
    sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors.properties
    sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors_fr.properties

Modified: sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/CoordinateSystems.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/CoordinateSystems.java?rev=1544737&r1=1544736&r2=1544737&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/CoordinateSystems.java
[UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/CoordinateSystems.java
[UTF-8] Sat Nov 23 02:36:41 2013
@@ -17,6 +17,7 @@
 package org.apache.sis.referencing.cs;
 
 import java.util.Arrays;
+import java.util.NoSuchElementException;
 import javax.measure.unit.Unit;
 import javax.measure.converter.UnitConverter;
 import javax.measure.converter.LinearConverter;
@@ -27,7 +28,9 @@ import org.opengis.referencing.operation
 import org.apache.sis.measure.Units;
 import org.apache.sis.util.Static;
 import org.apache.sis.util.Classes;
+import org.apache.sis.util.CharSequences;
 import org.apache.sis.util.resources.Errors;
+import org.apache.sis.internal.referencing.AxisDirections;
 import org.apache.sis.referencing.operation.matrix.Matrices;
 import org.apache.sis.referencing.operation.matrix.MatrixSIS;
 
@@ -58,6 +61,47 @@ public final class CoordinateSystems ext
     }
 
     /**
+     * Returns an axis direction code from the given direction name.
+     * Names are case-insensitive. They may be:
+     *
+     * <ul>
+     *   <li>Cardinal directions like "<cite>north</cite>" and "<cite>east</cite>".</li>
+     *   <li>Inter-cardinal directions "<cite>north-east</cite>" and "<cite>south-south-east</cite>",
+     *       using either {@code '-'}, {@code '_'} or spaces as separator between the cardinal
points.</li>
+     *   <li>Directions from a pole like "<cite>South along 180 deg</cite>"
and "<cite>South along 90° East</cite>",
+     *       using either the {@code "deg"} or {@code "°"} symbol.</li>
+     * </ul>
+     *
+     * @param  name The direction name (e.g. "north", "north-east", <i>etc.</i>).
+     * @return The axis direction for the given name.
+     * @throws NoSuchElementException if the given name is not a known axis direction.
+     */
+    public static AxisDirection directionOf(String name) throws NoSuchElementException {
+        ensureNonNull("direction", name);
+        name = CharSequences.trimWhitespaces(name);
+        AxisDirection candidate = AxisDirections.valueOf(name);
+        if (candidate != null) {
+            return candidate;
+        }
+        /*
+         * Some EPSG direction names are of the form "South along 180 deg". We check that
the
+         * direction before "along" is valid and create a new axis direction if it is. We
can
+         * not just replace "South along 180 deg" by "South" because the same CRS may use
two
+         * of those directions. For example EPSG:32661 has the following axis direction:
+         *
+         * South along 180 deg
+         * South along 90 deg East
+         */
+        final DirectionAlongMeridian meridian = DirectionAlongMeridian.parse(name);
+        if (meridian != null) {
+            candidate = meridian.getDirection();
+            assert candidate == AxisDirections.valueOf(meridian.toString());
+            return candidate;
+        }
+        throw new NoSuchElementException(Errors.format(Errors.Keys.UnknownAxisDirection_1,
name));
+    }
+
+    /**
      * Returns the arithmetic (counterclockwise) angle from the first axis direction to the
second direction,
      * in decimal <strong>degrees</strong>. This method returns a value between
-180° and +180°,
      * or {@link Double#NaN NaN} if no angle can be computed.

Modified: sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DirectionAlongMeridian.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DirectionAlongMeridian.java?rev=1544737&r1=1544736&r2=1544737&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DirectionAlongMeridian.java
[UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DirectionAlongMeridian.java
[UTF-8] Sat Nov 23 02:36:41 2013
@@ -206,11 +206,11 @@ final class DirectionAlongMeridian imple
      * get (extracted from the EPSG database):
      *
      * <table class="sis">
-     *   <tr><td>North along 90 deg East,</td>  <td>North along 0
deg</td></tr>
-     *   <tr><td>North along 75 deg West,</td>  <td>North along 165
deg West</td></tr>
-     *   <tr><td>South along 90 deg West,</td>  <td>South along 0
deg</td></tr>
-     *   <tr><td>South along 180 deg,</td>      <td>South along 90
deg West</td></tr>
-     *   <tr><td>North along 130 deg West</td>  <td>North along 140
deg East</td></tr>
+     *   <tr><td>North along 90° East,</td>  <td>North along 0°</td></tr>
+     *   <tr><td>North along 75° West,</td>  <td>North along 165°
West</td></tr>
+     *   <tr><td>South along 90° West,</td>  <td>South along 0°</td></tr>
+     *   <tr><td>South along 180°,</td>      <td>South along 90°
West</td></tr>
+     *   <tr><td>North along 130° West</td>  <td>North along 140°
East</td></tr>
      * </table>
      */
     @Override

Modified: sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors.java?rev=1544737&r1=1544736&r2=1544737&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors.java
[UTF-8] (original)
+++ sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors.java
[UTF-8] Sat Nov 23 02:36:41 2013
@@ -626,6 +626,11 @@ public final class Errors extends Indexe
         public static final int UnexpectedFileFormat_2 = 92;
 
         /**
+         * Axis direction “{0}” is unknown.
+         */
+        public static final int UnknownAxisDirection_1 = 133;
+
+        /**
          * Command “{0}” is not recognized.
          */
         public static final int UnknownCommand_1 = 102;

Modified: sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors.properties
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors.properties?rev=1544737&r1=1544736&r2=1544737&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors.properties
[ISO-8859-1] (original)
+++ sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors.properties
[ISO-8859-1] Sat Nov 23 02:36:41 2013
@@ -137,6 +137,7 @@ UnexpectedChange_1                = Unex
 UnexpectedEndOfFile_1             = Unexpected end of file while reading \u201c{0}\u201d.
 UnexpectedEndOfString_1           = More characters were expected at the end of \u201c{0}\u201d.
 UnexpectedFileFormat_2            = File \u201c{1}\u201d seems to be encoded in an other
format than {0}.
+UnknownAxisDirection_1            = Axis direction \u201c{0}\u201d is unknown.
 UnknownCommand_1                  = Command \u201c{0}\u201d is not recognized.
 UnknownEnumValue_1                = Unknown enumeration value: {0}.
 UnknownFormatFor_1                = Format of \u201c{0}\u201d is not recognized.

Modified: sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors_fr.properties
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors_fr.properties?rev=1544737&r1=1544736&r2=1544737&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors_fr.properties
[ISO-8859-1] (original)
+++ sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors_fr.properties
[ISO-8859-1] Sat Nov 23 02:36:41 2013
@@ -126,6 +126,7 @@ UnexpectedChange_1                = Chan
 UnexpectedEndOfFile_1             = Fin de fichier inattendue lors de la lecture de \u201c{0}\u201d.
 UnexpectedEndOfString_1           = D\u2019autres caract\u00e8res \u00e9taient attendus \u00e0
la fin du texte \u201c{0}\u201d.
 UnexpectedFileFormat_2            = Le fichier \u201c{1}\u201d semble \u00eatre encod\u00e9
dans un autre format que {0}.
+UnknownAxisDirection_1            = La direction d\u2019axe \u201c{0}\u201d n\u2019est pas
reconnue.
 UnknownCommand_1                  = La commande \u201c{0}\u201d n\u2019est pas reconnue.
 UnknownEnumValue_1                = Valeur d\u2019\u00e9num\u00e9ration inconnue: {0}.
 UnknownFormatFor_1                = Le format de \u201c{0}\u201d n\u2019est pas reconnu.



Mime
View raw message