sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1683704 - in /sis/branches/JDK8/core: sis-metadata/src/main/java/org/apache/sis/internal/metadata/ sis-metadata/src/test/java/org/apache/sis/internal/metadata/ sis-metadata/src/test/java/org/apache/sis/test/suite/ sis-referencing/src/main/...
Date Fri, 05 Jun 2015 10:26:17 GMT
Author: desruisseaux
Date: Fri Jun  5 10:26:17 2015
New Revision: 1683704

URL: http://svn.apache.org/r1683704
Log:
OSGi: moved VerticalDatumTypes from "sis-referencing" to "sis-metadata" module, for allowing
us to move GeodeticObjectParser later.

Added:
    sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/VerticalDatumTypes.java
      - copied, changed from r1682275, sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/VerticalDatumTypes.java
    sis/branches/JDK8/core/sis-metadata/src/test/java/org/apache/sis/internal/metadata/VerticalDatumTypesTest.java
      - copied, changed from r1682275, sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/VerticalDatumTypesTest.java
Removed:
    sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/VerticalDatumTypes.java
    sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/VerticalDatumTypesTest.java
Modified:
    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/io/wkt/GeodeticObjectParser.java
    sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultVerticalDatum.java
    sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/CommonCRSTest.java
    sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/datum/DefaultVerticalDatumTest.java
    sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/datum/HardCodedDatum.java
    sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/test/suite/ReferencingTestSuite.java

Copied: sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/VerticalDatumTypes.java
(from r1682275, sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/VerticalDatumTypes.java)
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/VerticalDatumTypes.java?p2=sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/VerticalDatumTypes.java&p1=sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/VerticalDatumTypes.java&r1=1682275&r2=1683704&rev=1683704&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/VerticalDatumTypes.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/VerticalDatumTypes.java
[UTF-8] Fri Jun  5 10:26:17 2015
@@ -14,12 +14,13 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.sis.internal.referencing;
+package org.apache.sis.internal.metadata;
 
 import org.opengis.util.CodeList;
+import org.opengis.util.GenericName;
+import org.opengis.metadata.Identifier;
 import org.opengis.referencing.datum.VerticalDatum;
 import org.opengis.referencing.datum.VerticalDatumType;
-import org.apache.sis.referencing.IdentifiedObjects;
 import org.apache.sis.util.StringBuilders;
 
 
@@ -33,7 +34,7 @@ import org.apache.sis.util.StringBuilder
  *
  * @author  Martin Desruisseaux (IRD, Geomatys)
  * @since   0.4
- * @version 0.4
+ * @version 0.6
  * @module
  */
 public final class VerticalDatumTypes implements CodeList.Filter {
@@ -115,15 +116,46 @@ public final class VerticalDatumTypes im
      * 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 {@link VerticalDatumType#OTHER_SURFACE}.</p>
+     * If the type can not be determined, defaults on {@link VerticalDatumType#OTHER_SURFACE}.</p>
      *
      * @param  datum The datum for which to guess a type.
      * @return A datum type, or {@link VerticalDatumType#OTHER_SURFACE} if none can be guessed.
      */
     public static VerticalDatumType guess(final VerticalDatum datum) {
-        final VerticalDatumType type = CodeList.valueOf(VerticalDatumType.class,
-                new VerticalDatumTypes(IdentifiedObjects.getName(datum, null)));
-        return (type != null) ? type : VerticalDatumType.OTHER_SURFACE;
+        final Identifier identifier = datum.getName();
+        if (identifier != null) {
+            final VerticalDatumType type = guess(identifier.getCode());
+            if (type != null) {
+                return type;
+            }
+        }
+        for (final GenericName alias : datum.getAlias()) {
+            final VerticalDatumType type = guess(alias.tip().toString());
+            if (type != null) {
+                return type;
+            }
+        }
+        return VerticalDatumType.OTHER_SURFACE;
+    }
+
+    /**
+     * Guesses the type of a datum of the given name. This method attempts to guess only
if the given name
+     * contains at least one letter. If the type can not be determined, returns {@code null}.
+     *
+     * @param  name Name of the datum for which to guess a type, or {@code null}.
+     * @return A datum type, or {@code null} if none can be guessed.
+     */
+    private static VerticalDatumType guess(final String name) {
+        if (name != null) {
+            for (int i=0; i<name.length();) {
+                final int c = name.codePointAt(i);
+                if (Character.isLetter(c)) {
+                    return CodeList.valueOf(VerticalDatumType.class, new VerticalDatumTypes(name));
+                }
+                i += Character.charCount(c);
+            }
+        }
+        return null;
     }
 
     /**
@@ -152,7 +184,7 @@ public final class VerticalDatumTypes im
 
     /**
      * Returns {@code true} if the name of the given code is the prefix of a word in the
datum name.
-     * We don't test the characters following the prefix because the word may be incomplete
+     * We do not test the characters following the prefix because the word may be incomplete
      * (e.g. {@code "geoid"} versus {@code "geoidal"}).
      *
      * @param code The code to test.

Copied: sis/branches/JDK8/core/sis-metadata/src/test/java/org/apache/sis/internal/metadata/VerticalDatumTypesTest.java
(from r1682275, sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/VerticalDatumTypesTest.java)
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-metadata/src/test/java/org/apache/sis/internal/metadata/VerticalDatumTypesTest.java?p2=sis/branches/JDK8/core/sis-metadata/src/test/java/org/apache/sis/internal/metadata/VerticalDatumTypesTest.java&p1=sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/VerticalDatumTypesTest.java&r1=1682275&r2=1683704&rev=1683704&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/VerticalDatumTypesTest.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-metadata/src/test/java/org/apache/sis/internal/metadata/VerticalDatumTypesTest.java
[UTF-8] Fri Jun  5 10:26:17 2015
@@ -14,7 +14,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.sis.internal.referencing;
+package org.apache.sis.internal.metadata;
 
 import org.opengis.referencing.datum.VerticalDatumType;
 import org.apache.sis.test.DependsOnMethod;
@@ -30,7 +30,7 @@ import static org.junit.Assert.*;
  *
  * @author  Martin Desruisseaux (Geomatys)
  * @since   0.4
- * @version 0.4
+ * @version 0.6
  * @module
  */
 public final strictfp class VerticalDatumTypesTest extends TestCase {

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=1683704&r1=1683703&r2=1683704&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] Fri Jun  5 10:26:17 2015
@@ -33,6 +33,7 @@ import org.junit.BeforeClass;
     org.apache.sis.internal.metadata.WKTKeywordsTest.class,
     org.apache.sis.internal.metadata.NameMeaningTest.class,
     org.apache.sis.internal.metadata.MetadataUtilitiesTest.class,
+    org.apache.sis.internal.metadata.VerticalDatumTypesTest.class,
     org.apache.sis.internal.metadata.OtherLocalesTest.class,
 
     // Classes using Java reflection.

Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/io/wkt/GeodeticObjectParser.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/io/wkt/GeodeticObjectParser.java?rev=1683704&r1=1683703&r2=1683704&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/io/wkt/GeodeticObjectParser.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/io/wkt/GeodeticObjectParser.java
[UTF-8] Fri Jun  5 10:26:17 2015
@@ -52,9 +52,9 @@ import org.apache.sis.referencing.Common
 import org.apache.sis.metadata.iso.ImmutableIdentifier;
 import org.apache.sis.metadata.iso.citation.Citations;
 import org.apache.sis.internal.metadata.WKTKeywords;
+import org.apache.sis.internal.metadata.VerticalDatumTypes;
 import org.apache.sis.internal.metadata.ReferencingServices;
 import org.apache.sis.internal.referencing.Legacy;
-import org.apache.sis.internal.referencing.VerticalDatumTypes;
 import org.apache.sis.internal.util.LocalizedParseException;
 import org.apache.sis.internal.system.DefaultFactories;
 import org.apache.sis.util.resources.Errors;

Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultVerticalDatum.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultVerticalDatum.java?rev=1683704&r1=1683703&r2=1683704&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultVerticalDatum.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultVerticalDatum.java
[UTF-8] Fri Jun  5 10:26:17 2015
@@ -30,7 +30,7 @@ import org.apache.sis.util.ComparisonMod
 import org.apache.sis.internal.jaxb.Context;
 import org.apache.sis.internal.jaxb.LegacyNamespaces;
 import org.apache.sis.internal.metadata.WKTKeywords;
-import org.apache.sis.internal.referencing.VerticalDatumTypes;
+import org.apache.sis.internal.metadata.VerticalDatumTypes;
 
 import static org.apache.sis.util.ArgumentChecks.ensureNonNull;
 import static org.apache.sis.internal.referencing.ReferencingUtilities.canSetProperty;

Modified: sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/CommonCRSTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/CommonCRSTest.java?rev=1683704&r1=1683703&r2=1683704&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/CommonCRSTest.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/CommonCRSTest.java
[UTF-8] Fri Jun  5 10:26:17 2015
@@ -30,7 +30,7 @@ import org.opengis.referencing.cs.Ellips
 import org.opengis.referencing.datum.TemporalDatum;
 import org.opengis.referencing.datum.VerticalDatum;
 import org.opengis.referencing.datum.VerticalDatumType;
-import org.apache.sis.internal.referencing.VerticalDatumTypes;
+import org.apache.sis.internal.metadata.VerticalDatumTypes;
 import org.apache.sis.internal.util.Constants;
 import org.apache.sis.test.DependsOnMethod;
 import org.apache.sis.test.DependsOn;

Modified: sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/datum/DefaultVerticalDatumTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/datum/DefaultVerticalDatumTest.java?rev=1683704&r1=1683703&r2=1683704&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/datum/DefaultVerticalDatumTest.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/datum/DefaultVerticalDatumTest.java
[UTF-8] Fri Jun  5 10:26:17 2015
@@ -21,14 +21,13 @@ import javax.xml.bind.Marshaller;
 import javax.xml.bind.Unmarshaller;
 import javax.xml.bind.JAXBException;
 import org.opengis.referencing.datum.VerticalDatumType;
-import org.apache.sis.internal.referencing.VerticalDatumTypes;
+import org.apache.sis.internal.metadata.VerticalDatumTypes;
 import org.apache.sis.internal.jaxb.LegacyNamespaces;
 import org.apache.sis.io.wkt.Convention;
 import org.apache.sis.util.Version;
 import org.apache.sis.xml.XML;
 import org.apache.sis.xml.MarshallerPool;
 import org.apache.sis.test.XMLTestCase;
-import org.apache.sis.test.DependsOn;
 import org.junit.Test;
 
 import static java.util.Collections.singletonMap;
@@ -44,7 +43,6 @@ import static org.apache.sis.referencing
  * @version 0.4
  * @module
  */
-@DependsOn(org.apache.sis.internal.referencing.VerticalDatumTypesTest.class)
 public final strictfp class DefaultVerticalDatumTest extends XMLTestCase {
     /**
      * An XML file in this package containing a vertical datum definition.

Modified: sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/datum/HardCodedDatum.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/datum/HardCodedDatum.java?rev=1683704&r1=1683703&r2=1683704&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/datum/HardCodedDatum.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/datum/HardCodedDatum.java
[UTF-8] Fri Jun  5 10:26:17 2015
@@ -25,7 +25,7 @@ import org.opengis.referencing.datum.Pix
 import org.opengis.referencing.datum.VerticalDatumType;
 import org.apache.sis.test.mock.GeodeticDatumMock;
 import org.apache.sis.referencing.NamedIdentifier;
-import org.apache.sis.internal.referencing.VerticalDatumTypes;
+import org.apache.sis.internal.metadata.VerticalDatumTypes;
 import org.apache.sis.metadata.iso.citation.Citations;
 
 import static org.opengis.referencing.datum.Datum.*;

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=1683704&r1=1683703&r2=1683704&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] Fri Jun  5 10:26:17 2015
@@ -33,7 +33,6 @@ import org.junit.BeforeClass;
     org.apache.sis.internal.referencing.FormulasTest.class,
     org.apache.sis.internal.referencing.j2d.ShapeUtilitiesTest.class,
     org.apache.sis.internal.referencing.AxisDirectionsTest.class,
-    org.apache.sis.internal.referencing.VerticalDatumTypesTest.class,
     org.apache.sis.internal.referencing.PositionalAccuracyConstantTest.class,
     org.apache.sis.internal.referencing.ReferencingUtilitiesTest.class,
     org.apache.sis.internal.jaxb.referencing.CodeTest.class,



Mime
View raw message