sis-commits mailing list archives

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

URL: http://svn.apache.org/r1544734
Log:
Partial port of DefaultCartesianCS.

Added:
    sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultAffineCS.java
  (with props)
Modified:
    sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/io/wkt/Convention.java
    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/DefaultCartesianCS.java
    sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/iso/Types.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/io/wkt/Convention.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/io/wkt/Convention.java?rev=1544734&r1=1544733&r2=1544734&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/io/wkt/Convention.java
[UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/io/wkt/Convention.java
[UTF-8] Sat Nov 23 02:04:36 2013
@@ -211,7 +211,7 @@ public enum Convention {
      * <var>{@linkplain DefaultCoordinateSystemAxis#NORTHING Northing}</var>
      * in metres, where the "Other" axis is toward prime meridian.
      */
-    private static final DefaultCartesianCS LEGACY = new DefaultCartesianCS("Legacy",
+    private static final DefaultCartesianCS LEGACY = new DefaultCartesianCS(singletonMap(NAME_KEY,
"Legacy geocentric"),
             new DefaultCoordinateSystemAxis(singletonMap(NAME_KEY, "Geocentric X"), "X",
AxisDirection.OTHER, SI.METRE),
             new DefaultCoordinateSystemAxis(singletonMap(NAME_KEY, "Geocentric Y"), "Y",
AxisDirection.EAST,  SI.METRE),
             new DefaultCoordinateSystemAxis(singletonMap(NAME_KEY, "Geocentric Z"), "Z",
AxisDirection.NORTH, SI.METRE));

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=1544734&r1=1544733&r2=1544734&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:04:36 2013
@@ -31,12 +31,14 @@ import org.apache.sis.util.resources.Err
 import org.apache.sis.referencing.operation.matrix.Matrices;
 import org.apache.sis.referencing.operation.matrix.MatrixSIS;
 
+import static org.apache.sis.util.ArgumentChecks.ensureNonNull;
+
 // Related to JDK7
 import java.util.Objects;
 
 
 /**
- * Utility methods working on {@link CoordinateSystem} objects.
+ * Utility methods working on {@link CoordinateSystem} objects and their axes.
  *
  * @author  Martin Desruisseaux (IRD, Geomatys)
  * @since   0.4 (derived from geotk-2.0)
@@ -45,12 +47,78 @@ import java.util.Objects;
  */
 public final class CoordinateSystems extends Static {
     /**
+     * Number of directions from "North", "North-North-East", "North-East", etc.
+     */
+    static final int COMPASS_DIRECTION_COUNT = 16;
+
+    /**
      * Do not allow instantiation of this class.
      */
     private CoordinateSystems() {
     }
 
     /**
+     * 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.
+     *
+     * <p>A positive angle denotes a right-handed system, while a negative angle denotes
a left-handed system.
+     * Example:</p>
+     *
+     * <ul>
+     *   <li>The angle from {@link AxisDirection#EAST EAST} to {@link AxisDirection#NORTH
NORTH} is 90°</li>
+     *   <li>The angle from {@link AxisDirection#SOUTH SOUTH} to {@link AxisDirection#WEST
WEST} is -90°</li>
+     *   <li>The angle from "<cite>North along 90° East</cite>" to "<cite>North
along 0°</cite>" is 90°.</li>
+     * </ul>
+     *
+     * @param  source The source axis direction.
+     * @param  target The target axis direction.
+     * @return The arithmetic angle (in degrees) of the rotation to apply on a line pointing
toward
+     *         the source direction in order to make it point toward the target direction,
or
+     *         {@link Double#NaN} if this value can not be computed.
+     */
+    public static double angle(final AxisDirection source, final AxisDirection target) {
+        ensureNonNull("source", source);
+        ensureNonNull("target", target);
+        // Tests for NORTH, SOUTH, EAST, EAST-NORTH-EAST, etc. directions.
+        final int compass = getCompassAngle(source, target);
+        if (compass != Integer.MIN_VALUE) {
+            return compass * (360.0 / COMPASS_DIRECTION_COUNT);
+        }
+        // Tests for "South along 90 deg East", etc. directions.
+        final DirectionAlongMeridian src = DirectionAlongMeridian.parse(source);
+        if (src != null) {
+            final DirectionAlongMeridian tgt = DirectionAlongMeridian.parse(target);
+            if (tgt != null) {
+                return src.getAngle(tgt);
+            }
+        }
+        return Double.NaN;
+    }
+
+    /**
+     * Tests for angle on compass only (do not tests angle between direction along meridians).
+     * Returns {@link Integer#MIN_VALUE} if the angle can't be computed.
+     */
+    static int getCompassAngle(final AxisDirection source, final AxisDirection target) {
+        final int base = AxisDirection.NORTH.ordinal();
+        final int src  = source.ordinal() - base;
+        if (src >= 0 && src < COMPASS_DIRECTION_COUNT) {
+            int tgt = target.ordinal() - base;
+            if (tgt >= 0 && tgt < COMPASS_DIRECTION_COUNT) {
+                tgt = src - tgt;
+                if (tgt < -COMPASS_DIRECTION_COUNT/2) {
+                    tgt += COMPASS_DIRECTION_COUNT;
+                } else if (tgt > COMPASS_DIRECTION_COUNT/2) {
+                    tgt -= COMPASS_DIRECTION_COUNT;
+                }
+                return tgt;
+            }
+        }
+        return Integer.MIN_VALUE;
+    }
+
+    /**
      * Returns the axis direction for the specified coordinate system.
      *
      * @param  cs The coordinate system.

Added: sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultAffineCS.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultAffineCS.java?rev=1544734&view=auto
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultAffineCS.java
(added)
+++ sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultAffineCS.java
[UTF-8] Sat Nov 23 02:04:36 2013
@@ -0,0 +1,151 @@
+/*
+ * 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.referencing.cs;
+
+import java.util.Map;
+import javax.measure.unit.SI;
+import javax.measure.unit.Unit;
+import org.opengis.referencing.cs.AffineCS;
+import org.opengis.referencing.cs.CartesianCS;
+import org.opengis.referencing.cs.AxisDirection;
+import org.opengis.referencing.cs.CoordinateSystemAxis;
+import org.apache.sis.internal.referencing.AxisDirections;
+import org.apache.sis.measure.Units;
+import org.apache.sis.util.Immutable;
+
+
+/**
+ * A 2- or 3-dimensional coordinate system with straight axes that are not necessarily orthogonal.
+ *
+ * <table class="sis">
+ * <tr><th>Used with CRS type(s)</th></tr>
+ * <tr><td>
+ *   {@linkplain org.geotoolkit.referencing.crs.DefaultEngineeringCRS Engineering},
+ *   {@linkplain org.geotoolkit.referencing.crs.DefaultImageCRS       Image}
+ * </td></tr></table>
+ *
+ * @author  Martin Desruisseaux (IRD, Geomatys)
+ * @since   0.4 (derived from geotk-2.0)
+ * @version 0.4
+ * @module
+ */
+@Immutable
+public class DefaultAffineCS extends AbstractCS implements AffineCS {
+    /**
+     * Serial number for inter-operability with different versions.
+     */
+    private static final long serialVersionUID = 7977674229369042440L;
+
+    /**
+     * Constructs a coordinate system of arbitrary dimension. This constructor is
+     * not public because {@code AffineCS} are restricted to 2 and 3 dimensions.
+     */
+    DefaultAffineCS(final Map<String,?> properties, final CoordinateSystemAxis[] axis)
{
+        super(properties, axis);
+    }
+
+    /**
+     * Constructs a two-dimensional coordinate system from a set of properties.
+     * The properties map is given unchanged to the
+     * {@linkplain AbstractCS#AbstractCS(Map,CoordinateSystemAxis[]) super-class constructor}.
+     *
+     * @param properties The properties to be given to the identified object.
+     * @param axis0 The first axis.
+     * @param axis1 The second axis.
+     */
+    public DefaultAffineCS(final Map<String,?>   properties,
+                           final CoordinateSystemAxis axis0,
+                           final CoordinateSystemAxis axis1)
+    {
+        super(properties, axis0, axis1);
+    }
+
+    /**
+     * Constructs a three-dimensional coordinate system from a set of properties.
+     * The properties map is given unchanged to the superclass constructor.
+     *
+     * @param properties The properties to be given to the identified object.
+     * @param axis0 The first axis.
+     * @param axis1 The second axis.
+     * @param axis2 The third axis.
+     */
+    public DefaultAffineCS(final Map<String,?>   properties,
+                           final CoordinateSystemAxis axis0,
+                           final CoordinateSystemAxis axis1,
+                           final CoordinateSystemAxis axis2)
+    {
+        super(properties, axis0, axis1, axis2);
+    }
+
+    /**
+     * Creates a new coordinate system with the same values than the specified one.
+     * This copy constructor provides a way to convert an arbitrary implementation into a
SIS one
+     * or a user-defined one (as a subclass), usually in order to leverage some implementation-specific
API.
+     *
+     * <p>This constructor performs a shallow copy, i.e. the properties are not cloned.</p>
+     *
+     * @param cs The coordinate system to copy.
+     *
+     * @see #castOrCopy(AffineCS)
+     */
+    protected DefaultAffineCS(final AffineCS cs) {
+        super(cs);
+    }
+
+    /**
+     * Returns a SIS coordinate system implementation with the same values than the given
arbitrary
+     * implementation. If the given object is {@code null}, then this method returns {@code
null}.
+     * Otherwise if the given object is already a SIS implementation, then the given object
is
+     * returned unchanged. Otherwise a new SIS implementation is created and initialized
to the
+     * attribute values of the given object.
+     *
+     * <p>This method checks for the {@link CartesianCS} sub-interface. If that interface
is found,
+     * then this method delegates to the corresponding {@code castOrCopy} static method.</p>
+     *
+     * @param  object The object to get as a SIS implementation, or {@code null} if none.
+     * @return A SIS implementation containing the values of the given object (may be the
+     *         given object itself), or {@code null} if the argument was null.
+     */
+    public static DefaultAffineCS castOrCopy(final AffineCS object) {
+        if (object instanceof CartesianCS) {
+            return DefaultCartesianCS.castOrCopy((CartesianCS) object);
+        }
+        return (object == null) || (object instanceof DefaultAffineCS)
+                ? (DefaultAffineCS) object : new DefaultAffineCS(object);
+    }
+
+    /**
+     * Returns {@code true} if the given axis direction is allowed for this coordinate system.
+     * The default implementation accepts all directions except temporal ones
+     * (i.e. {@link AxisDirection#FUTURE FUTURE} and {@link AxisDirection#PAST PAST}).
+     */
+    @Override
+    final boolean isCompatibleDirection(final AxisDirection direction) {
+        return !AxisDirection.FUTURE.equals(AxisDirections.absolute(direction));
+    }
+
+    /**
+     * Returns {@code true} if the given unit is compatible with {@linkplain SI#METRE metres}.
+     * In addition, this method also accepts {@link Unit#ONE}, which is used for coordinates
in a grid.
+     * This method is invoked at construction time for checking units compatibility.
+     */
+    @Override
+    final boolean isCompatibleUnit(final AxisDirection direction, final Unit<?> unit)
{
+        return Units.isLinear(unit) || Unit.ONE.equals(unit);
+        // Note: this condition is also coded in PredefinedCS.rightHanded(AffineCS).
+    }
+}

Propchange: sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultAffineCS.java
------------------------------------------------------------------------------
    svn:eol-style = native

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

Modified: sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultCartesianCS.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultCartesianCS.java?rev=1544734&r1=1544733&r2=1544734&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultCartesianCS.java
[UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultCartesianCS.java
[UTF-8] Sat Nov 23 02:04:36 2013
@@ -16,57 +16,142 @@
  */
 package org.apache.sis.referencing.cs;
 
-import java.util.Set;
-import java.util.Collection;
-import org.opengis.util.GenericName;
-import org.opengis.util.InternationalString;
-import org.opengis.referencing.ReferenceIdentifier;
+import java.util.Map;
 import org.opengis.referencing.cs.CartesianCS;
+import org.opengis.referencing.cs.AxisDirection;
 import org.opengis.referencing.cs.CoordinateSystemAxis;
+import org.apache.sis.internal.referencing.Formulas;
+import org.apache.sis.util.resources.Errors;
+import org.apache.sis.util.Immutable;
+
+
+/**
+ * A 1-, 2-, or 3-dimensional Cartesian coordinate system. The position of points are relative
+ * to orthogonal straight axes in the 2- and 3-dimensional cases. In the 1-dimensional case,
+ * the coordinate system contains a single straight coordinate axis. All axes shall have
the
+ * same linear unit of measure.
+ *
+ * <table class="sis">
+ * <tr><th>Used with CRS type(s)</th></tr>
+ * <tr><td>
+ *   {@linkplain org.geotoolkit.referencing.crs.DefaultGeocentricCRS  Geocentric},
+ *   {@linkplain org.geotoolkit.referencing.crs.DefaultProjectedCRS   Projected},
+ *   {@linkplain org.geotoolkit.referencing.crs.DefaultEngineeringCRS Engineering},
+ *   {@linkplain org.geotoolkit.referencing.crs.DefaultImageCRS       Image}
+ * </td></tr></table>
+ *
+ * @author  Martin Desruisseaux (IRD, Geomatys)
+ * @since   0.4 (derived from geotk-2.0)
+ * @version 0.4
+ * @module
+ */
+@Immutable
+public class DefaultCartesianCS extends DefaultAffineCS implements CartesianCS {
+    /**
+     * Serial number for inter-operability with different versions.
+     */
+    private static final long serialVersionUID = -6182037957705712945L;
+
+    public static final DefaultCartesianCS GEOCENTRIC = null; // TODO: Not supported yet.
+
+    /**
+     * Constructs a one-dimensional coordinate system from a set of properties.
+     * The properties map is given unchanged to the
+     * {@linkplain AbstractCS#AbstractCS(Map,CoordinateSystemAxis[]) super-class constructor}.
+     *
+     * @param properties The properties to be given to the identified object.
+     * @param axis The axis.
+     */
+    public DefaultCartesianCS(final Map<String,?>   properties,
+                              final CoordinateSystemAxis axis)
+    {
+        super(properties, new CoordinateSystemAxis[] {axis});
+        ensurePerpendicularAxis();
+    }
 
+    /**
+     * Constructs a two-dimensional coordinate system from a set of properties.
+     * The properties map is given unchanged to the
+     * {@linkplain AbstractCS#AbstractCS(Map,CoordinateSystemAxis[]) super-class constructor}.
+     *
+     * @param properties The properties to be given to the identified object.
+     * @param axis0 The first axis.
+     * @param axis1 The second axis.
+     */
+    public DefaultCartesianCS(final Map<String,?>   properties,
+                              final CoordinateSystemAxis axis0,
+                              final CoordinateSystemAxis axis1)
+    {
+        super(properties, axis0, axis1);
+        ensurePerpendicularAxis();
+    }
 
-public class DefaultCartesianCS implements CartesianCS {
-    public static final DefaultCartesianCS GEOCENTRIC = null; // Not supported yet.
-
-    public DefaultCartesianCS(final String               name,
+    /**
+     * Constructs a three-dimensional coordinate system from a set of properties.
+     * The properties map is given unchanged to the
+     * {@linkplain AbstractCS#AbstractCS(Map,CoordinateSystemAxis[]) super-class constructor}.
+     *
+     * @param properties The properties to be given to the identified object.
+     * @param axis0 The first axis.
+     * @param axis1 The second axis.
+     * @param axis2 The third axis.
+     */
+    public DefaultCartesianCS(final Map<String,?>   properties,
                               final CoordinateSystemAxis axis0,
                               final CoordinateSystemAxis axis1,
                               final CoordinateSystemAxis axis2)
     {
+        super(properties, axis0, axis1, axis2);
+        ensurePerpendicularAxis();
     }
 
-    @Override
-    public ReferenceIdentifier getName() {
-        throw new UnsupportedOperationException("Not supported yet.");
-    }
-
-    @Override
-    public Collection<GenericName> getAlias() {
-        throw new UnsupportedOperationException("Not supported yet.");
-    }
-
-    @Override
-    public Set<ReferenceIdentifier> getIdentifiers() {
-        throw new UnsupportedOperationException("Not supported yet.");
-    }
-
-    @Override
-    public InternationalString getRemarks() {
-        throw new UnsupportedOperationException("Not supported yet.");
-    }
-
-    @Override
-    public int getDimension() {
-        throw new UnsupportedOperationException("Not supported yet.");
-    }
-
-    @Override
-    public CoordinateSystemAxis getAxis(int i) throws IndexOutOfBoundsException {
-        throw new UnsupportedOperationException("Not supported yet.");
-    }
-
-    @Override
-    public String toWKT() throws UnsupportedOperationException {
-        throw new UnsupportedOperationException("Not supported yet.");
+    /**
+     * Creates a new coordinate system with the same values than the specified one.
+     * This copy constructor provides a way to convert an arbitrary implementation into a
SIS one
+     * or a user-defined one (as a subclass), usually in order to leverage some implementation-specific
API.
+     *
+     * <p>This constructor performs a shallow copy, i.e. the properties are not cloned.</p>
+     *
+     * @param cs The coordinate system to copy.
+     *
+     * @see #castOrCopy(CartesianCS)
+     */
+    protected DefaultCartesianCS(final CartesianCS cs) {
+        super(cs);
+        ensurePerpendicularAxis();
+    }
+
+    /**
+     * Returns a SIS coordinate system implementation with the same values than the given
arbitrary
+     * implementation. If the given object is {@code null}, then this method returns {@code
null}.
+     * Otherwise if the given object is already a SIS implementation, then the given object
is
+     * returned unchanged. Otherwise a new SIS implementation is created and initialized
to the
+     * attribute values of the given object.
+     *
+     * @param  object The object to get as a SIS implementation, or {@code null} if none.
+     * @return A SIS implementation containing the values of the given object (may be the
+     *         given object itself), or {@code null} if the argument was null.
+     */
+    public static DefaultCartesianCS castOrCopy(final CartesianCS object) {
+        return (object == null) || (object instanceof DefaultCartesianCS)
+                ? (DefaultCartesianCS) object : new DefaultCartesianCS(object);
+    }
+
+    /**
+     * Ensures that all axes are perpendicular.
+     */
+    private void ensurePerpendicularAxis() throws IllegalArgumentException {
+        final int dimension = getDimension();
+        for (int i=0; i<dimension; i++) {
+            final AxisDirection axis0 = getAxis(i).getDirection();
+            for (int j=i; ++j<dimension;) {
+                final AxisDirection axis1 = getAxis(j).getDirection();
+                final double angle = CoordinateSystems.angle(axis0, axis1); // May be NaN,
which we accept.
+                if (Math.abs(Math.abs(angle) - 90) > Formulas.ANGULAR_TOLERANCE) {
+                    throw new IllegalArgumentException(Errors.format(
+                            Errors.Keys.NonPerpendicularDirections_2, axis0, axis1));
+                }
+            }
+        }
     }
 }

Modified: sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/iso/Types.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/iso/Types.java?rev=1544734&r1=1544733&r2=1544734&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/iso/Types.java [UTF-8]
(original)
+++ sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/iso/Types.java [UTF-8]
Sat Nov 23 02:04:36 2013
@@ -67,6 +67,11 @@ import org.apache.sis.internal.system.De
  */
 public final class Types extends Static {
     /**
+     * The separator character between class name and attribute name in resource files.
+     */
+    private static final char SEPARATOR = '.';
+
+    /**
      * The types for ISO 19115 UML identifiers. The keys are UML identifiers. Values
      * are either class names as {@link String} objects, or the {@link Class} instances.
      * This map will be built only when first needed.
@@ -180,10 +185,10 @@ public final class Types extends Static 
      * results without the need of resource bundles. For better results, consider using
      * {@link #getCodeTitle(CodeList)} instead.
      *
-     * <p>The current heuristic implementation iterates over {@linkplain CodeList#names()
all
-     * code names}, selects the longest one excluding the {@linkplain CodeList#name() field
name}
-     * if possible, then {@linkplain CharSequences#camelCaseToSentence(CharSequence) makes
a sentence}
-     * from that name. Examples:</p>
+     * <p>The current heuristic implementation iterates over {@linkplain CodeList#names()
all code names},
+     * selects the longest one excluding the {@linkplain CodeList#name() field name} if possible,
then
+     * {@linkplain CharSequences#camelCaseToSentence(CharSequence) makes a sentence} from
that name.
+     * Examples:</p>
      *
      * <ul>
      *   <li>{@code getCodeLabel(AxisDirection.NORTH)} returns {@code "North"}.</li>
@@ -243,7 +248,7 @@ public final class Types extends Static 
         if (code != null) {
             final String resources = getResources(code.getClass().getName());
             if (resources != null) {
-                return new Description(resources, getListName(code) + '.' + getCodeName(code));
+                return new Description(resources, resourceKey(code));
             }
         }
         return null;
@@ -285,7 +290,7 @@ public final class Types extends Static 
             if (name != null) {
                 final String resources = getResources(type.getName());
                 if (resources != null) {
-                    return new Description(resources, name + '.' + property);
+                    return new Description(resources, name + SEPARATOR + property);
                 }
             }
         }
@@ -349,7 +354,7 @@ public final class Types extends Static 
          * Returns a fallback if no resource is found.
          */
         String fallback() {
-            return CharSequences.camelCaseToSentence(key.substring(key.lastIndexOf('.') +
1)).toString();
+            return CharSequences.camelCaseToSentence(key.substring(key.lastIndexOf(SEPARATOR)
+ 1)).toString();
         }
     }
 
@@ -382,7 +387,7 @@ public final class Types extends Static 
          * @param code The code list for which to create a title.
          */
         CodeTitle(final CodeList<?> code) {
-            super("org.opengis.metadata.CodeLists", getListName(code) + '.' + getCodeName(code));
+            super("org.opengis.metadata.CodeLists", resourceKey(code));
             this.code = code;
         }
 
@@ -411,6 +416,17 @@ public final class Types extends Static 
     }
 
     /**
+     * Returns the resource key for the given code list.
+     */
+    static String resourceKey(final CodeList<?> code) {
+        String key = getCodeName(code);
+        if (key.indexOf(SEPARATOR) < 0) {
+            key = getListName(code) + SEPARATOR + key;
+        }
+        return key;
+    }
+
+    /**
      * Returns all known values for the given type of code list.
      * Note that the size of the returned array may growth between different invocations
of this method,
      * since users can add their own codes to an existing list.

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=1544734&r1=1544733&r2=1544734&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:04:36 2013
@@ -491,6 +491,11 @@ public final class Errors extends Indexe
         public static final int NonLinearUnit_1 = 47;
 
         /**
+         * Axis directions {0} and {1} are not perpendicular.
+         */
+        public static final int NonPerpendicularDirections_2 = 132;
+
+        /**
          * “{0}” is not a scale unit.
          */
         public static final int NonScaleUnit_1 = 48;

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=1544734&r1=1544733&r2=1544734&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:04:36 2013
@@ -106,6 +106,7 @@ NonInvertibleTransform            = Tran
 NonAngularUnit_1                  = \u201c{0}\u201d is not an angular unit.
 NonLinearUnit_1                   = \u201c{0}\u201d is not a linear unit.
 NonLinearUnitConversion_2         = Unit conversion from \u201c{0}\u201d to \u201c{1}\u201d
is non-linear.
+NonPerpendicularDirections_2      = Axis directions {0} and {1} are not perpendicular.
 NonScaleUnit_1                    = \u201c{0}\u201d is not a scale unit.
 NonTemporalUnit_1                 = \u201c{0}\u201d is not a time unit.
 NonUniformScale                   = Scale is not uniform.

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=1544734&r1=1544733&r2=1544734&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:04:36 2013
@@ -96,6 +96,7 @@ NonInvertibleTransform            = La t
 NonAngularUnit_1                  = \u201c{0}\u201d n\u2019est pas une unit\u00e9 d\u2019angles.
 NonLinearUnit_1                   = \u201c{0}\u201d n\u2019est pas une unit\u00e9 de longueurs.
 NonLinearUnitConversion_2         = La conversion des unit\u00e9s \u201c{0}\u201d vers \u201c{1}\u201d
n\u2019est pas lin\u00e9aire.
+NonPerpendicularDirections_2      = Les directions {0} et {1} ne sont pas perpendiculaires.
 NonScaleUnit_1                    = \u201c{0}\u201d n\u2019est pas une unit\u00e9 d\u2019\u00e9chelles.
 NonTemporalUnit_1                 = \u201c{0}\u201d n\u2019est pas une unit\u00e9 de temps.
 NonUniformScale                   = L\u2019\u00e9chelle n\u2019est pas uniforme.



Mime
View raw message