sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject [sis] 02/04: Move the declaration of ESRI_DATUM_PREFIX constant in order to allow its reuse from other classes.
Date Sat, 12 Jan 2019 16:55:19 GMT
This is an automated email from the ASF dual-hosted git repository.

desruisseaux pushed a commit to branch geoapi-4.0
in repository https://gitbox.apache.org/repos/asf/sis.git

commit 01d63a7ff4720fbbdc6e70748302ac693b8910ee
Author: Martin Desruisseaux <martin.desruisseaux@geomatys.com>
AuthorDate: Sat Jan 12 16:03:21 2019 +0100

    Move the declaration of ESRI_DATUM_PREFIX constant in order to allow its reuse from other
classes.
---
 .../sis/internal/referencing/WKTUtilities.java       |  5 +++++
 .../apache/sis/referencing/datum/AbstractDatum.java  | 20 ++++++++++----------
 2 files changed, 15 insertions(+), 10 deletions(-)

diff --git a/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/WKTUtilities.java
b/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/WKTUtilities.java
index 9c32785..a0596a2 100644
--- a/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/WKTUtilities.java
+++ b/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/WKTUtilities.java
@@ -68,6 +68,11 @@ import org.apache.sis.math.DecimalFunctions;
  */
 public final class WKTUtilities extends Static {
     /**
+     * The prefix used by ESRI at the beginning of datum names.
+     */
+    public static final String ESRI_DATUM_PREFIX = "D_";
+
+    /**
      * Do not allow instantiation of this class.
      */
     private WKTUtilities() {
diff --git a/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/AbstractDatum.java
b/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/AbstractDatum.java
index 1355ac2..8d8957d 100644
--- a/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/AbstractDatum.java
+++ b/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/AbstractDatum.java
@@ -42,6 +42,7 @@ import org.apache.sis.io.wkt.Formatter;
 
 import static org.apache.sis.util.Utilities.deepEquals;
 import static org.apache.sis.util.collection.Containers.property;
+import static org.apache.sis.internal.referencing.WKTUtilities.ESRI_DATUM_PREFIX;
 
 // Branch-dependent imports
 import java.util.Objects;
@@ -95,11 +96,6 @@ public class AbstractDatum extends AbstractIdentifiedObject implements
Datum {
     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.
      *
@@ -364,6 +360,10 @@ public class AbstractDatum extends AbstractIdentifiedObject implements
Datum {
     /**
      * A function for simplifying a {@link Datum} name before comparison.
      *
+     * <p>Note: if heuristic rules are modified, consider updating {@code EPSGDataAccess}
accordingly.</p>
+     *
+     * @see org.apache.sis.referencing.factory.sql.EPSGDataAccess#toDatumPattern(String,
StringBuilder)
+     *
      * @since 0.7
      */
     static class Simplifier extends NameToIdentifier.Simplifier {
@@ -376,8 +376,8 @@ public class AbstractDatum extends AbstractIdentifiedObject implements
Datum {
         /** Simplify the given datum name. */
         @Override protected CharSequence apply(CharSequence name) {
             name = super.apply(name);
-            if (CharSequences.startsWith(name, ESRI_PREFIX, false)) {
-                name = name.subSequence(ESRI_PREFIX.length(), name.length());
+            if (CharSequences.startsWith(name, ESRI_DATUM_PREFIX, false)) {
+                name = name.subSequence(ESRI_DATUM_PREFIX.length(), name.length());
             }
             return name;
         }
@@ -463,11 +463,11 @@ public class AbstractDatum extends AbstractIdentifiedObject implements
Datum {
         String name = IdentifiedObjects.getName(this, authority);
         if (name == null) {
             name = IdentifiedObjects.getName(this, null);
-            if (name == null) { // Should never happen, but be safe.
+            if (name == null) {                                 // Should never happen, but
be safe.
                 return super.formatTo(formatter);
             }
-            if ("ESRI".equalsIgnoreCase(Citations.toCodeSpace(authority)) && !name.startsWith(ESRI_PREFIX))
{
-                name = ESRI_PREFIX + name;
+            if ("ESRI".equalsIgnoreCase(Citations.toCodeSpace(authority)) && !name.startsWith(ESRI_DATUM_PREFIX))
{
+                name = ESRI_DATUM_PREFIX + name;
             }
         }
         formatter.append(name, ElementKind.DATUM);


Mime
View raw message