sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1684858 - in /sis/branches/JDK8: core/sis-metadata/src/main/java/org/apache/sis/io/wkt/ core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/ core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/extent/ core/sis-utility/src/m...
Date Thu, 11 Jun 2015 11:43:46 GMT
Author: desruisseaux
Date: Thu Jun 11 11:43:46 2015
New Revision: 1684858

URL: http://svn.apache.org/r1684858
Log:
WKT: consolidation in the way some metadata are constructed and in the report of warnings.

Modified:
    sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/Element.java
    sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/GeodeticObjectParser.java
    sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/Parser.java
    sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/WKTFormat.java
    sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/DefaultIdentifier.java
    sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/extent/DefaultGeographicDescription.java
    sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/Characters.java
    sis/branches/JDK8/storage/sis-netcdf/src/main/java/org/apache/sis/storage/netcdf/MetadataReader.java

Modified: sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/Element.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/Element.java?rev=1684858&r1=1684857&r2=1684858&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/Element.java [UTF-8]
(original)
+++ sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/Element.java [UTF-8]
Thu Jun 11 11:43:46 2015
@@ -574,8 +574,9 @@ final class Element {
      * If the given {@code ignored} map is non-null, then this method will add the keywords
      * of ignored elements in that map as below:
      * <ul>
-     *   <li>Keyword of ignored elements are the keys. Note that a key may be null.</li>
-     *   <li>Keywords of the elements that contained ignored elements are the values.</li>
+     *   <li><b>Keys</b>: keyword of ignored elements. Note that a key
may be null.</li>
+     *   <li><b>Values</b>: keywords of all elements containing an element
identified by the above-cited key.
+     *       This list is used for helping the users to locate the ignored elements.</li>
      * </ul>
      *
      * @param  ignoredElements The collection where to declare ignored elements, or {@code
null}.

Modified: sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/GeodeticObjectParser.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/GeodeticObjectParser.java?rev=1684858&r1=1684857&r2=1684858&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/GeodeticObjectParser.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/GeodeticObjectParser.java
[UTF-8] Thu Jun 11 11:43:46 2015
@@ -358,7 +358,15 @@ final class GeodeticObjectParser extends
              * so the name in WKT is often not compliant with the name actually defined by
the authority.
              */
         }
-        if (!parent.isEmpty()) {    // Optimization for a common case, since most elements
do not contain any of the childs below.
+        /*
+         * Other metadata (SCOPE, AREA, etc.).  ISO 19162 said that at most one of each type
shall be present,
+         * but our parser accepts an arbitrary amount of some kinds of metadata. They can
be recognized by the
+         * 'while' loop.
+         *
+         * Most WKT do not contain any of those metadata, so we perform an 'isEmpty()' check
as an optimization
+         * for those common cases.
+         */
+        if (!parent.isEmpty()) {
             /*
              * Example: SCOPE["Large scale topographic mapping and cadastre."]
              */
@@ -369,19 +377,16 @@ final class GeodeticObjectParser extends
             }
             /*
              * Example: AREA["Netherlands offshore."]
-             *
-             * ISO 19162 said that at most one of each type shall be present,
-             * but our parser accepts an arbitrary amount of any extent below.
              */
             DefaultExtent extent = null;
             while ((element = parent.pullOptionalElement(WKTKeywords.Area, null)) != null)
{
                 final String area = element.pullString("area");
                 element.close(ignoredElements);
                 if (extent == null) extent = new DefaultExtent();
-                extent.getGeographicElements().add(new DefaultGeographicDescription(null,
area));
+                extent.getGeographicElements().add(new DefaultGeographicDescription(area));
             }
             /*
-             * Example: BBOX[51.43,2.54,55.77,6.40]
+             * Example: BBOX[51.43, 2.54, 55.77, 6.40]
              */
             while ((element = parent.pullOptionalElement(WKTKeywords.BBox, null)) != null)
{
                 final double southBoundLatitude = element.pullDouble("southBoundLatitude");
@@ -412,15 +417,22 @@ final class GeodeticObjectParser extends
              *
              * TODO: syntax like TIMEEXTENT[“Jurassic”, “Quaternary”] is not yet
supported.
              * See https://issues.apache.org/jira/browse/SIS-163
+             *
+             * This operation requires the the sis-temporal module. If not available,
+             * we will report a warning and leave the temporal extent missing.
              */
             while ((element = parent.pullOptionalElement(WKTKeywords.TimeExtent, null)) !=
null) {
                 final Date startTime = element.pullDate("startTime");
                 final Date endTime   = element.pullDate("endTime");
                 element.close(ignoredElements);
-                final DefaultTemporalExtent time = new DefaultTemporalExtent();
-                time.setBounds(startTime, endTime);
-                if (extent == null) extent = new DefaultExtent();
-                extent.getTemporalElements().add(time);
+                try {
+                    final DefaultTemporalExtent t = new DefaultTemporalExtent();
+                    t.setBounds(startTime, endTime);
+                    if (extent == null) extent = new DefaultExtent();
+                    extent.getTemporalElements().add(t);
+                } catch (UnsupportedOperationException e) {
+                    warning(parent, WKTKeywords.TimeExtent, e);
+                }
             }
         }
         parent.close(ignoredElements);
@@ -438,9 +450,9 @@ final class GeodeticObjectParser extends
      * Unit was a mandatory element in WKT 1, but became optional in WKT 2 because the unit
may be specified
      * in each {@code AXIS[…]} element instead than for the whole coordinate system.
      *
-     * @param  parent  The parent element.
-     * @param  keyword The unit keyword.
-     * @param  unit    The contextual unit, usually {@code SI.METRE} or {@code SI.RADIAN}.
+     * @param  parent   The parent element.
+     * @param  keyword  The unit keyword.
+     * @param  baseUnit The base unit, usually {@code SI.METRE} or {@code SI.RADIAN}.
      * @return The {@code "UNIT"} element as an {@link Unit} object.
      * @throws ParseException if the {@code "UNIT"} can not be parsed.
      *
@@ -448,17 +460,17 @@ final class GeodeticObjectParser extends
      *       {@link Unit} which implements {@link IdentifiedObject} in a future version.
      */
     @SuppressWarnings("unchecked")
-    private <Q extends Quantity> Unit<Q> parseUnit(final Element parent, final
String keyword, final Unit<Q> unit)
+    private <Q extends Quantity> Unit<Q> parseUnit(final Element parent, final
String keyword, final Unit<Q> baseUnit)
             throws ParseException
     {
         final Element element = parent.pullOptionalElement(keyword, WKTKeywords.Unit);
         if (element == null) {
-            return unit.equals(SI.RADIAN) ? (Unit<Q>) NonSI.DEGREE_ANGLE : unit;
+            return baseUnit.equals(SI.RADIAN) ? (Unit<Q>) NonSI.DEGREE_ANGLE : baseUnit;
         }
         final String  name   = element.pullString("name");
         final double  factor = element.pullDouble("factor");
         parseMetadataAndClose(element, name);
-        return Units.multiply(unit, factor);
+        return Units.multiply(baseUnit, factor);
     }
 
     /**

Modified: sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/Parser.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/Parser.java?rev=1684858&r1=1684857&r2=1684858&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/Parser.java [UTF-8]
(original)
+++ sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/Parser.java [UTF-8]
Thu Jun 11 11:43:46 2015
@@ -29,6 +29,8 @@ import java.text.ParseException;
 import java.text.SimpleDateFormat;
 import org.opengis.util.FactoryException;
 import org.apache.sis.util.Workaround;
+import org.apache.sis.util.Exceptions;
+import org.apache.sis.util.resources.Errors;
 import org.apache.sis.internal.metadata.WKTParser;
 
 import static org.apache.sis.util.ArgumentChecks.ensureNonNull;
@@ -90,10 +92,21 @@ abstract class Parser implements WKTPars
     /**
      * Keyword of unknown elements. The ISO 19162 specification requires that we ignore unknown
elements,
      * but we will nevertheless report them as warnings.
+     * The meaning of this map is:
+     * <ul>
+     *   <li><b>Keys</b>: keyword of ignored elements. Note that a key
may be null.</li>
+     *   <li><b>Values</b>: keywords of all elements containing an element
identified by the above-cited key.
+     *       This list is used for helping the users to locate the ignored elements.</li>
+     * </ul>
      */
     final Map<String, List<String>> ignoredElements;
 
     /**
+     * The first warning (other than {@link #ignoredElements}) that occurred during the parsing.
+     */
+    private String warning;
+
+    /**
      * Constructs a parser using the specified set of symbols.
      *
      * @param symbols       The set of symbols to use.
@@ -162,6 +175,7 @@ abstract class Parser implements WKTPars
      * @throws ParseException if the string can not be parsed.
      */
     public Object parseObject(final String text, final ParsePosition position) throws ParseException
{
+        warning = null;
         ignoredElements.clear();
         final Element element = new Element(new Element(this, text, position));
         final Object object = parseObject(element);
@@ -210,4 +224,28 @@ abstract class Parser implements WKTPars
         }
         return dateFormat.parse(text, position);
     }
+
+    /**
+     * Reports a non-fatal warning while parsing a WKT.
+     *
+     * @param parent  The parent element.
+     * @param keyword The keyword of the element that we can not parse.
+     * @param e The exception that occurred while parsing a WKT.
+     */
+    final void warning(final Element parent, final String keyword, final Exception e) {
+        if (warning != null) {
+            warning = Errors.getResources(errorLocale).getString(Errors.Keys.UnparsableStringInElement_2,
parent.keyword, keyword);
+            final String message = Exceptions.getLocalizedMessage(e, errorLocale);
+            if (message != null) {
+                warning = warning + ' ' + message;
+            }
+        }
+    }
+
+    /**
+     * Returns the warnings that occurred during the last parsing, or {@code null} if none.
+     */
+    final String getWarning() {
+        return warning;
+    }
 }

Modified: sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/WKTFormat.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/WKTFormat.java?rev=1684858&r1=1684857&r2=1684858&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/WKTFormat.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/WKTFormat.java
[UTF-8] Thu Jun 11 11:43:46 2015
@@ -186,6 +186,11 @@ public class WKTFormat extends CompoundF
     private transient Map<Class<?>,Factory> factories;
 
     /**
+     * Whether the last operation was a parsing or formatting operation.
+     */
+    private transient boolean lastOperationIsParsing;
+
+    /**
      * Creates a format for the given locale and timezone. The given locale will be used
for
      * {@link org.opengis.util.InternationalString} localization; this is <strong>not</strong>
      * the locale for number format.
@@ -499,6 +504,8 @@ public class WKTFormat extends CompoundF
      */
     @Override
     public Object parse(final CharSequence text, final ParsePosition pos) throws ParseException
{
+        ArgumentChecks.ensureNonNull("text", text);
+        ArgumentChecks.ensureNonNull("pos",  pos);
         if (parser == null) {
             if (factories == null) {
                 factories = new HashMap<>();
@@ -508,6 +515,7 @@ public class WKTFormat extends CompoundF
                     (DateFormat)   getFormat(Date.class),
                     convention, false, getLocale(Locale.Category.DISPLAY), factories);
         }
+        lastOperationIsParsing = true;
         return parser.parseObject(text.toString(), pos);
     }
 
@@ -554,13 +562,14 @@ public class WKTFormat extends CompoundF
             updateFormatter(formatter);
             this.formatter = formatter;
         }
+        formatter.clear();
+        lastOperationIsParsing = false;
         final boolean valid;
         try {
             formatter.setBuffer(buffer);
             valid = formatter.appendElement(object) || formatter.appendValue(object);
         } finally {
             formatter.setBuffer(null);
-            formatter.clear();
         }
         if (!valid) {
             throw new ClassCastException(Errors.format(
@@ -594,13 +603,18 @@ public class WKTFormat extends CompoundF
     }
 
     /**
-     * If a warning occurred during the last WKT {@linkplain #format(Object, Appendable)
formatting}, returns
-     * the warning. Otherwise returns {@code null}. The warning is cleared every time a new
object is formatted.
+     * If a warning occurred during the last WKT {@linkplain #parse(CharSequence, ParsePosition)
parsing} or
+     * {@linkplain #format(Object, Appendable) formatting}, returns the warning. Otherwise
returns {@code null}.
+     * The warning is cleared every time a new object is parsed or formatted.
      *
      * @return The last warning, or {@code null} if none.
      */
     public String getWarning() {
-        return (formatter != null) ? formatter.getErrorMessage() : null;
+        if (lastOperationIsParsing) {
+            return (parser != null) ? parser.getWarning() : null;
+        } else {
+            return (formatter != null) ? formatter.getErrorMessage() : null;
+        }
     }
 
     /**
@@ -612,6 +626,7 @@ public class WKTFormat extends CompoundF
     public WKTFormat clone() {
         final WKTFormat clone = (WKTFormat) super.clone();
         clone.formatter = null; // Do not share the formatter.
+        clone.parser = null;
         return clone;
     }
 }

Modified: sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/DefaultIdentifier.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/DefaultIdentifier.java?rev=1684858&r1=1684857&r2=1684858&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/DefaultIdentifier.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/DefaultIdentifier.java
[UTF-8] Thu Jun 11 11:43:46 2015
@@ -22,6 +22,7 @@ import javax.xml.bind.annotation.XmlRoot
 import org.opengis.metadata.Identifier;
 import org.opengis.metadata.citation.Citation;
 import org.opengis.util.InternationalString;
+import org.apache.sis.internal.util.Citations;
 
 
 /**
@@ -76,7 +77,7 @@ import org.opengis.util.InternationalStr
  * @author  Touraïvane (IRD)
  * @author  Cédric Briançon (Geomatys)
  * @since   0.3
- * @version 0.5
+ * @version 0.6
  * @module
  *
  * @see ImmutableIdentifier
@@ -139,15 +140,32 @@ public class DefaultIdentifier extends I
 
     /**
      * Creates an identifier initialized to the given authority and code.
+     * This constructor automatically initializes the {@linkplain #getCodeSpace() code space}
to a value inferred
+     * from the given {@code authority}, if a suitable value can be found. This constructor
proceeds by searching
+     * for the first suitable property in the following list:
+     *
+     * <ol>
+     *   <li>The value of {@link org.apache.sis.xml.IdentifierSpace#getName()}.</li>
+     *   <li>A {@linkplain org.apache.sis.metadata.iso.citation.DefaultCitation#getIdentifiers()
citation identifier}
+     *       which is a valid
+     *       {@linkplain org.apache.sis.util.CharSequences#isUnicodeIdentifier(CharSequence)
unicode identifier}.</li>
+     *   <li>Only if the citation had no identifier, a citation title or
+     *       {@linkplain org.apache.sis.metadata.iso.citation.DefaultCitation#getAlternateTitles()
alternate title}
+     *       which is a valid
+     *       {@linkplain org.apache.sis.util.CharSequences#isUnicodeIdentifier(CharSequence)
unicode identifier}.</li>
+     * </ol>
      *
      * @param authority The organization or party responsible for definition and maintenance
      *                  of the code, or {@code null} if none.
      * @param code      The alphanumeric value identifying an instance in the namespace,
      *                  or {@code null} if none.
+     *
+     * @see org.apache.sis.metadata.iso.citation.Citations#getUnicodeIdentifier(Citation)
      */
     public DefaultIdentifier(final Citation authority, final String code) {
         this.authority = authority;
         this.code = code;
+        codeSpace = Citations.getCodeSpace(authority);
     }
 
     /**
@@ -197,6 +215,12 @@ public class DefaultIdentifier extends I
 
     /**
      * Returns the alphanumeric value identifying an instance in the namespace.
+     * The code is optionally from a controlled list or pattern.
+     *
+     * <div class="note"><b>Example:</b> {@code "4326"}.</div>
+     *
+     * The code is mandatory according ISO specification, but this {@code DefaultIdentifier}
+     * implementation does not enforce this restriction.
      *
      * @return Value identifying an instance in the namespace.
      */
@@ -218,6 +242,9 @@ public class DefaultIdentifier extends I
 
     /**
      * Returns the identifier or namespace in which the code is valid.
+     * This is often the {@linkplain #getAuthority() authority}'s abbreviation, but not necessarily.
+     *
+     * <div class="note"><b>Example:</b> {@code "EPSG"}.</div>
      *
      * @return The identifier code space, or {@code null} if none.
      *
@@ -246,6 +273,8 @@ public class DefaultIdentifier extends I
      * uses versions. When appropriate, the edition is identified by the effective date,
      * coded using ISO 8601 date format.
      *
+     * <div class="note"><b>Example:</b> the version of the underlying
EPSG database.</div>
+     *
      * @return The version, or {@code null} if not available.
      */
     @Override
@@ -266,6 +295,8 @@ public class DefaultIdentifier extends I
     /**
      * Returns the natural language description of the meaning of the code value.
      *
+     * <div class="note"><b>Example:</b> "World Geodetic System 1984".</div>
+     *
      * @return The natural language description, or {@code null} if none.
      *
      * @since 0.5
@@ -288,8 +319,9 @@ public class DefaultIdentifier extends I
     }
 
     /**
-     * Organization or party responsible for definition and maintenance of the
-     * {@linkplain #getCode() code}.
+     * Organization or party responsible for definition and maintenance of the {@linkplain
#getCode() code}.
+     * The organization's abbreviation is often the same than this identifier {@linkplain
#getCodeSpace() code space},
+     * but not necessarily.
      *
      * @return The authority, or {@code null} if not available.
      */
@@ -300,8 +332,7 @@ public class DefaultIdentifier extends I
     }
 
     /**
-     * Sets the organization or party responsible for definition and maintenance of the
-     * {@linkplain #getCode() code}.
+     * Sets the organization or party responsible for definition and maintenance of the {@linkplain
#getCode() code}.
      *
      * @param newValue The new authority.
      */

Modified: sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/extent/DefaultGeographicDescription.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/extent/DefaultGeographicDescription.java?rev=1684858&r1=1684857&r2=1684858&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/extent/DefaultGeographicDescription.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/extent/DefaultGeographicDescription.java
[UTF-8] Thu Jun 11 11:43:46 2015
@@ -19,14 +19,26 @@ package org.apache.sis.metadata.iso.exte
 import javax.xml.bind.annotation.XmlType;
 import javax.xml.bind.annotation.XmlElement;
 import javax.xml.bind.annotation.XmlRootElement;
+import org.opengis.util.InternationalString;
 import org.opengis.metadata.Identifier;
 import org.opengis.metadata.citation.Citation;
 import org.opengis.metadata.extent.GeographicDescription;
 import org.apache.sis.metadata.iso.DefaultIdentifier;
+import org.apache.sis.util.CharSequences;
+import org.apache.sis.util.iso.Types;
 
 
 /**
  * Description of the geographic area using identifiers.
+ * The area is given by a {@linkplain #getGeographicIdentifier() geographic identifier},
+ * which may be a code in the codespace of some authority (for example an EPSG code).
+ * In addition, the geographic identifier can optionally have a
+ * {@linkplain DefaultIdentifier#getDescription() natural language description}.
+ *
+ * <div class="note"><b>Example:</b>
+ * a geographic area may be identified by the {@code 1731} code in the {@code EPSG} codespace.
+ * The natural language description for {@code EPSG:1731} can be <cite>“France –
mainland north of 48.15°N”</cite>.
+ * </div>
  *
  * <p><b>Limitations:</b></p>
  * <ul>
@@ -41,7 +53,7 @@ import org.apache.sis.metadata.iso.Defau
  * @author  Touraïvane (IRD)
  * @author  Cédric Briançon (Geomatys)
  * @since   0.3
- * @version 0.3
+ * @version 0.6
  * @module
  */
 @XmlType(name = "EX_GeographicDescription_Type")
@@ -64,16 +76,57 @@ public class DefaultGeographicDescriptio
     }
 
     /**
-     * Creates an inclusive geographic description initialized to the specified value.
+     * Creates an inclusive geographic description initialized to the given identifier.
      * This constructor sets the {@linkplain #getInclusion() inclusion} property to {@code
true}.
      *
+     * <p><b>Usage note:</b> if the description is a sentence like “Netherlands
offshore”, it may not be suitable
+     * for the {@code code} argument. Callers may consider using the {@linkplain DefaultIdentifier#getDescription()
+     * identifier description} as an alternative and keep the code for a more compact string
(often a primary key).</p>
+     *
+     * <div class="note"><b>Example:</b>
+     * <code>new DefaultGeographicDescription({@link org.apache.sis.metadata.iso.citation.Citations#EPSG},
"1731")</code>
+     * can stand for <cite>“France – mainland north of 48.15°N”</cite>.</div>
+     *
      * @param authority The authority of the identifier code, or {@code null} if none.
      * @param code The identifier code used to represent a geographic area, or {@code null}
if none.
      */
     public DefaultGeographicDescription(final Citation authority, final String code) {
         super(true);
         if (authority != null || code != null) {
-            this.geographicIdentifier = new DefaultIdentifier(authority, code);
+            geographicIdentifier = new DefaultIdentifier(authority, code);
+        }
+    }
+
+    /**
+     * Creates an inclusive geographic description initialized to the given natural language
description.
+     * This constructor sets the {@linkplain #getInclusion() inclusion} property to {@code
true} and the
+     * {@linkplain DefaultIdentifier#getCode() identifier code} to one of the following choices:
+     *
+     * <ul>
+     *   <li>the given {@code description} string if it is a valid
+     *       {@linkplain CharSequences#isUnicodeIdentifier(CharSequence) Unicode identifier},</li>
+     *   <li>otherwise an {@linkplain CharSequences#camelCaseToAcronym(CharSequence)
acronym}
+     *       of the given {@code description}.</li>
+     * </ul>
+     *
+     * @param description The natural language description of the meaning of the code value,
or {@code null} if none.
+     *
+     * @since 0.6
+     */
+    public DefaultGeographicDescription(final CharSequence description) {
+        super(true);
+        if (description != null) {
+            final DefaultIdentifier id = new DefaultIdentifier();
+            if (CharSequences.isUnicodeIdentifier(description)) {
+                id.setCode(description.toString());
+                if (description instanceof InternationalString) {
+                    id.setDescription((InternationalString) description);
+                }
+            } else {
+                id.setCode(CharSequences.camelCaseToAcronym(description).toString());
+                id.setDescription(Types.toInternationalString(description));
+            }
+            geographicIdentifier = id;
         }
     }
 
@@ -121,6 +174,14 @@ public class DefaultGeographicDescriptio
     /**
      * Returns the identifier used to represent a geographic area.
      *
+     * <div class="note"><b>Example:</b>
+     * an identifier with the following properties:
+     * <ul>
+     *   <li>the {@code "EPSG"} code space,</li>
+     *   <li>the {@code "1731"} code, and</li>
+     *   <li>the <cite>“France – mainland north of 48.15°N”</cite>
description.</li>
+     * </ul></div>
+     *
      * @return The identifier used to represent a geographic area, or {@code null}.
      */
     @Override

Modified: sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/Characters.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/Characters.java?rev=1684858&r1=1684857&r2=1684858&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/Characters.java [UTF-8]
(original)
+++ sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/Characters.java [UTF-8]
Thu Jun 11 11:43:46 2015
@@ -16,6 +16,7 @@
  */
 package org.apache.sis.util;
 
+import org.opengis.metadata.citation.Citation;  // For javadoc.
 import org.apache.sis.util.resources.Errors;
 
 
@@ -266,10 +267,11 @@ public final class Characters extends St
      * <div class="section">Relationship with international standards</div>
      * ISO 19162:2015 §B.5.2 recommends to ignore spaces, case and the following characters
when comparing two
      * {@linkplain org.apache.sis.referencing.AbstractIdentifiedObject#getName() identified
object names}:
-     * “_” (underscore), “-” (minus sign), “/” (solidus), “(” (left parenthesis)
and “)” (right parenthesis).
+     * “{@code _}” (underscore), “{@code -}” (minus sign), “{@code /}” (solidus),
+     * “{@code (}” (left parenthesis) and “{@code )}” (right parenthesis).
      * The same specification also limits the set of valid characters in a name to the following
(§6.3.1):
      *
-     * <blockquote>{@literal A-Z a-z 0-9 _ [ ] ( ) { } < = > . , : ; + - (space)
% & ' " * ^ / \ ? | °}</blockquote>
+     * <blockquote>{@code A-Z a-z 0-9 _ [ ] ( ) { } < = > . , : ; + - (space)
% & ' " * ^ / \ ? | °}</blockquote>
      * <div class="note"><b>Note:</b> SIS does not enforce this restriction
in its programmatic API,
      * but may perform some character substitutions at <cite>Well Known Text</cite>
(WKT) formatting time.</div>
      *
@@ -296,19 +298,23 @@ public final class Characters extends St
         /**
          * The subset of all characters for which {@link Character#isLetterOrDigit(int)}
          * returns {@code true}. This subset includes the following general categories:
+         *
+         * <blockquote>
          * {@link Character#LOWERCASE_LETTER},
          * {@link Character#UPPERCASE_LETTER     UPPERCASE_LETTER},
          * {@link Character#TITLECASE_LETTER     TITLECASE_LETTER},
          * {@link Character#MODIFIER_LETTER      MODIFIER_LETTER},
          * {@link Character#OTHER_LETTER         OTHER_LETTER} and
          * {@link Character#DECIMAL_DIGIT_NUMBER DECIMAL_DIGIT_NUMBER}.
+         * </blockquote>
          *
-         * <p>SIS uses this filter when comparing two
+         * SIS uses this filter when comparing two
          * {@linkplain org.apache.sis.referencing.AbstractIdentifiedObject#getName() identified
object names}.
          * See the <cite>Relationship with international standards</cite> section
in this class javadoc
-         * for more information.</p>
+         * for more information.
          *
          * @see org.apache.sis.referencing.AbstractIdentifiedObject#isHeuristicMatchForName(String)
+         * @see org.apache.sis.metadata.iso.citation.Citations#identifierMatches(Citation,
String)
          */
         public static final Filter LETTERS_AND_DIGITS = new LettersAndDigits();
 
@@ -317,10 +323,13 @@ public final class Characters extends St
          * returns {@code true}, excluding {@linkplain Character#isIdentifierIgnorable(int)
ignorable} characters.
          * This subset includes all the {@link #LETTERS_AND_DIGITS} categories with the addition
of the following
          * ones:
+         *
+         * <blockquote>
          * {@link Character#LETTER_NUMBER},
          * {@link Character#CONNECTOR_PUNCTUATION CONNECTOR_PUNCTUATION},
          * {@link Character#NON_SPACING_MARK NON_SPACING_MARK} and
          * {@link Character#COMBINING_SPACING_MARK COMBINING_SPACING_MARK}.
+         * </blockquote>
          */
         public static final Filter UNICODE_IDENTIFIER = new UnicodeIdentifier();
 

Modified: sis/branches/JDK8/storage/sis-netcdf/src/main/java/org/apache/sis/storage/netcdf/MetadataReader.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-netcdf/src/main/java/org/apache/sis/storage/netcdf/MetadataReader.java?rev=1684858&r1=1684857&r2=1684858&view=diff
==============================================================================
--- sis/branches/JDK8/storage/sis-netcdf/src/main/java/org/apache/sis/storage/netcdf/MetadataReader.java
[UTF-8] (original)
+++ sis/branches/JDK8/storage/sis-netcdf/src/main/java/org/apache/sis/storage/netcdf/MetadataReader.java
[UTF-8] Thu Jun 11 11:43:46 2015
@@ -749,7 +749,7 @@ final class MetadataReader {
             if (extent == null) {
                 extent = new DefaultExtent();
             }
-            extent.setGeographicElements(singleton(new DefaultGeographicDescription(null,
identifier)));
+            extent.setGeographicElements(singleton(new DefaultGeographicDescription(identifier)));
         }
         return extent;
     }



Mime
View raw message