sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1545532 - in /sis/branches/JDK7/core/sis-referencing/src: main/java/org/apache/sis/referencing/cs/ main/java/org/apache/sis/referencing/datum/ test/java/org/apache/sis/referencing/datum/
Date Tue, 26 Nov 2013 03:32:01 GMT
Author: desruisseaux
Date: Tue Nov 26 03:32:00 2013
New Revision: 1545532

URL: http://svn.apache.org/r1545532
Log:
Implemented the special case for the "D_" prefix in ESRI datum names.

Modified:
    sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultCoordinateSystemAxis.java
    sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/AbstractDatum.java
    sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/datum/DefaultGeodeticDatumTest.java

Modified: sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultCoordinateSystemAxis.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultCoordinateSystemAxis.java?rev=1545532&r1=1545531&r2=1545532&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultCoordinateSystemAxis.java
[UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultCoordinateSystemAxis.java
[UTF-8] Tue Nov 26 03:32:00 2013
@@ -378,10 +378,10 @@ public class DefaultCoordinateSystemAxis
     }
 
     /**
-     * Returns {@code true} if either the {@linkplain #getName() primary name} or at least
-     * one {@linkplain #getAlias() alias} matches the specified string. This method performs
-     * all the search done by the {@linkplain AbstractIdentifiedObject#nameMatches(String)
-     * super-class}, with the addition of special processing for latitudes and longitudes:
+     * Returns {@code true} if either the {@linkplain #getName() primary name} or at least
one
+     * {@linkplain #getAlias() alias} "ends" with the specified string. This method performs
the
+     * search documented in the {@linkplain AbstractIdentifiedObject#nameMatches(String)
super-class},
+     * with the addition of special processing for latitudes and longitudes:
      *
      * <ul>
      *   <li>{@code "Lat"}, {@code "Latitude"}  and {@code "Geodetic latitude"}  are
considered equivalent.</li>

Modified: sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/AbstractDatum.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/AbstractDatum.java?rev=1545532&r1=1545531&r2=1545532&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/AbstractDatum.java
[UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/AbstractDatum.java
[UTF-8] Tue Nov 26 03:32:00 2013
@@ -71,6 +71,11 @@ public class AbstractDatum extends Abstr
     private static final long serialVersionUID = -4894180465652474930L;
 
     /**
+     * The prefix used by ESRI at the beginning of datum names.
+     */
+    private static final String ESRI_PREFIX = "D_";
+
+    /**
      * Description, possibly including coordinates, of the point or points used to anchor
the datum
      * to the Earth. Also known as the "origin", especially for Engineering and Image Datums.
      */
@@ -287,6 +292,34 @@ public class AbstractDatum extends Abstr
     }
 
     /**
+     * Returns {@code true} if either the {@linkplain #getName() primary name} or at least
one
+     * {@linkplain #getAlias() alias} "ends" with the specified string. This method performs
the
+     * search documented in the {@linkplain AbstractIdentifiedObject#nameMatches(String)
super-class},
+     * with the addition of following rules:
+     *
+     * <ul>
+     *   <li>If the given name or this datum name starts with the {@code "D_"} prefix,
+     *       then the prefix is ignored. That prefix is used in ESRI datum names.</li>
+     * </ul>
+     *
+     * @param  name The name to compare.
+     * @return {@code true} if the primary name of at least one alias matches the specified
{@code name}.
+     */
+    @Override
+    public boolean nameMatches(final String name) {
+        if (name.startsWith((ESRI_PREFIX))) {
+            if (super.nameMatches(name.substring(ESRI_PREFIX.length()))) {
+                return true;
+            }
+        } else if (getName().getCode().startsWith(ESRI_PREFIX)) {
+            if (super.nameMatches(ESRI_PREFIX.concat(name))) {
+                return true;
+            }
+        }
+        return super.nameMatches(name);
+    }
+
+    /**
      * Compares the specified object with this datum for equality.
      * If the {@code mode} argument value is {@link ComparisonMode#STRICT STRICT} or
      * {@link ComparisonMode#BY_CONTRACT BY_CONTRACT}, then all available properties are
compared including the

Modified: sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/datum/DefaultGeodeticDatumTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/datum/DefaultGeodeticDatumTest.java?rev=1545532&r1=1545531&r2=1545532&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/datum/DefaultGeodeticDatumTest.java
[UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/datum/DefaultGeodeticDatumTest.java
[UTF-8] Tue Nov 26 03:32:00 2013
@@ -91,6 +91,20 @@ public final strictfp class DefaultGeode
     }
 
     /**
+     * Tests {@link DefaultGeodeticDatum#nameMatches(String)}.
+     */
+    @Test
+    public void testNameMatches() {
+        final DefaultGeodeticDatum datum = new DefaultGeodeticDatum(WGS84);
+        assertFalse(datum.nameMatches("WGS72"));
+        assertTrue (datum.nameMatches("WGS84"));
+        assertTrue (datum.nameMatches("WGS 84"));
+        assertTrue (datum.nameMatches("WGS_84"));
+        assertTrue (datum.nameMatches("D_WGS_84"));
+        assertFalse(datum.nameMatches("E_WGS_84"));
+    }
+
+    /**
      * Tests {@link DefaultGeodeticDatum#getPositionVectorTransformation(GeodeticDatum, Extent)}.
      */
     @Test



Mime
View raw message