sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1812859 - in /sis/branches/JDK8/storage: sis-netcdf/src/main/java/org/apache/sis/storage/netcdf/ sis-storage/src/main/java/org/apache/sis/internal/storage/
Date Sat, 21 Oct 2017 22:45:55 GMT
Author: desruisseaux
Date: Sat Oct 21 22:45:55 2017
New Revision: 1812859

URL: http://svn.apache.org/viewvc?rev=1812859&view=rev
Log:
Add support for netCDF "metadata_linkage" and "coverage_content_type" attributes.
This complete https://issues.apache.org/jira/browse/SIS-171 for now.

Modified:
    sis/branches/JDK8/storage/sis-netcdf/src/main/java/org/apache/sis/storage/netcdf/AttributeNames.java
    sis/branches/JDK8/storage/sis-netcdf/src/main/java/org/apache/sis/storage/netcdf/MetadataReader.java
    sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/MetadataBuilder.java

Modified: sis/branches/JDK8/storage/sis-netcdf/src/main/java/org/apache/sis/storage/netcdf/AttributeNames.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-netcdf/src/main/java/org/apache/sis/storage/netcdf/AttributeNames.java?rev=1812859&r1=1812858&r2=1812859&view=diff
==============================================================================
--- sis/branches/JDK8/storage/sis-netcdf/src/main/java/org/apache/sis/storage/netcdf/AttributeNames.java
[UTF-8] (original)
+++ sis/branches/JDK8/storage/sis-netcdf/src/main/java/org/apache/sis/storage/netcdf/AttributeNames.java
[UTF-8] Sat Oct 21 22:45:55 2017
@@ -80,8 +80,8 @@ import org.opengis.metadata.extent.Geogr
  * {@value     #FLAG_MEANINGS}<br>
  * {@value     #FLAG_NAMES}<br>
  * {@value     #FLAG_VALUES}<br>
- * {@linkplain #TITLE "full_name"}<br>
  * </td><td style="width: 25%">
+ * {@linkplain #TITLE                 "full_name"}<br>
  * {@linkplain #GEOGRAPHIC_IDENTIFIER "geographic_identifier"}<br>
  * {@value     #GEOSPATIAL_BOUNDS}<br>
  * {@linkplain #GEOSPATIAL_BOUNDS "geospatial_bounds_crs"}<br>
@@ -99,14 +99,15 @@ import org.opengis.metadata.extent.Geogr
  * {@linkplain #VERTICAL  "geospatial_vertical_positive"}<br>
  * {@linkplain #VERTICAL  "geospatial_vertical_resolution"}<br>
  * {@linkplain #VERTICAL  "geospatial_vertical_units"}<br>
- * </td><td style="width: 25%">
  * {@value     #HISTORY}<br>
- * {@linkplain #IDENTIFIER               "id"}<br>
- * {@linkplain #CREATOR                  "institution"}<br>
- * {@linkplain #KEYWORDS                 "keywords"}<br>
- * {@linkplain #KEYWORDS                 "keywords_vocabulary"}<br>
+ * {@linkplain #IDENTIFIER "id"}<br>
+ * {@linkplain #CREATOR    "institution"}<br>
+ * </td><td style="width: 25%">
+ * {@linkplain #KEYWORDS "keywords"}<br>
+ * {@linkplain #KEYWORDS "keywords_vocabulary"}<br>
  * {@value     #LICENSE}<br>
  * {@value     #METADATA_CREATION}<br>
+ * {@value     #METADATA_LINK}<br>
  * {@linkplain #TITLE "name"}<br>
  * {@value     #NAMING_AUTHORITY}<br>
  * {@value     #PROCESSING_LEVEL}<br>
@@ -119,16 +120,16 @@ import org.opengis.metadata.extent.Geogr
  * {@linkplain #PUBLISHER "publisher_url"}<br>
  * {@value     #PURPOSE}<br>
  * {@value     #REFERENCES}<br>
- * </td><td style="width: 25%">
  * {@value     #SOURCE}<br>
  * {@linkplain #STANDARD_NAME "standard_name"}<br>
  * {@linkplain #STANDARD_NAME "standard_name_vocabulary"}<br>
  * {@value     #SUMMARY}<br>
- * {@linkplain #TIME          "time_coverage_duration"}<br>
- * {@linkplain #TIME          "time_coverage_end"}<br>
- * {@linkplain #TIME          "time_coverage_resolution"}<br>
- * {@linkplain #TIME          "time_coverage_start"}<br>
- * {@linkplain #TIME          "time_coverage_units"}<br>
+ * </td><td style="width: 25%">
+ * {@linkplain #TIME "time_coverage_duration"}<br>
+ * {@linkplain #TIME "time_coverage_end"}<br>
+ * {@linkplain #TIME "time_coverage_resolution"}<br>
+ * {@linkplain #TIME "time_coverage_start"}<br>
+ * {@linkplain #TIME "time_coverage_units"}<br>
  * {@value     #TITLE}<br>
  * {@value     #TOPIC_CATEGORY}<br>
  * </td></tr></table></blockquote>
@@ -180,31 +181,14 @@ public class AttributeNames {
      *
      * <table class="sis">
      * <caption>Names of netCDF attributes describing a keyword</caption>
-     * <tr>
-     *   <th            >Field in this class</th>
-     *   <th class="sep">{@link AttributeNames#IDENTIFIER    IDENTIFIER}</th>
-     *   <th class="sep">{@link AttributeNames#STANDARD_NAME STANDARD_NAME}</th>
-     *   <th            >{@link AttributeNames#KEYWORDS      KEYWORDS}</th>
-     *   <th            >{@link AttributeNames#PROGRAM       PROGRAM}</th>
-     *   <th            >{@link AttributeNames#PLATFORM      PLATFORM}</th>
-     *   <th            >{@link AttributeNames#INSTRUMENT    INSTRUMENT}</th>
-     * </tr><tr>
-     *   <td            >{@link #TEXT}</td>
-     *   <td class="sep">{@code "id"}</td>
-     *   <td class="sep">{@code "standard_name"}</td>
-     *   <td            >{@code "keywords"}</td>
-     *   <td            >{@code "program"}</td>
-     *   <td            >{@code "platform"}</td>
-     *   <td            >{@code "instrument"}</td>
-     * </tr><tr>
-     *   <td            >{@link #VOCABULARY}</td>
-     *   <td class="sep">{@code "naming_authority"}</td>
-     *   <td class="sep">{@code "standard_name_vocabulary"}</td>
-     *   <td            >{@code "keywords_vocabulary"}</td>
-     *   <td            ></td>
-     *   <td            >{@code "platform_vocabulary"}</td>
-     *   <td            >{@code "instrument_vocabulary"}</td>
-     * </tr></table>
+     * <tr><th>{@link AttributeNames} constant</th>                   
<th>{@link #TEXT}</th>           <th>{@link #VOCABULARY}</th></tr>
+     * <tr><td>{@link AttributeNames#IDENTIFIER    IDENTIFIER}</td>   
<td>{@code "id"}</td>            <td>{@code "naming_authority"}</td></tr>
+     * <tr><td>{@link AttributeNames#STANDARD_NAME STANDARD_NAME}</td>
<td>{@code "standard_name"}</td> <td>{@code "standard_name_vocabulary"}</td></tr>
+     * <tr><td>{@link AttributeNames#KEYWORDS      KEYWORDS}</td>     
<td>{@code "keywords"}</td>      <td>{@code "keywords_vocabulary"}</td></tr>
+     * <tr><td>{@link AttributeNames#PROGRAM       PROGRAM}</td>      
<td>{@code "program"}</td>       <td></td></tr>
+     * <tr><td>{@link AttributeNames#PLATFORM      PLATFORM}</td>     
<td>{@code "platform"}</td>      <td>{@code "platform_vocabulary"}</td></tr>
+     * <tr><td>{@link AttributeNames#INSTRUMENT    INSTRUMENT}</td>   
<td>{@code "instrument"}</td>    <td>{@code "instrument_vocabulary"}</td></tr>
+     * </table>
      *
      * <div class="note"><b>Note:</b>
      * The member names in this class are upper-cases because they should be considered as
constants.
@@ -1238,6 +1222,18 @@ public class AttributeNames {
     public static final String FLAG_MEANINGS = "flag_meanings";
 
     /**
+     * The {@value} attribute name for a URL that gives the location of more complete metadata.
+     * For example it may be the URL to an ISO 19115 metadata in XML format.
+     *
+     * <p><b>Path in ISO 19115:</b></p> <ul><li>{@link
Metadata} /
+     * {@link Metadata#getMetadataLinkages() metadataLinkage} /
+     * {@link OnlineResource#getLinkage() linkage}</li></ul>
+     *
+     * @since 0.8
+     */
+    public static final String METADATA_LINK = "metadata_link";
+
+    /**
      * For subclass constructors only. {@code AttributeNames} may be sub-classed by communities
      * defining domain-specific attributes in addition to the ones defined by the CF convention.
      */

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=1812859&r1=1812858&r2=1812859&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] Sat Oct 21 22:45:55 2017
@@ -379,24 +379,39 @@ split:  while ((start = CharSequences.sk
     }
 
     /**
+     * Creates a URI form the given path, or returns {@code null} if the given URL is null
or can not be parsed.
+     * In the later case, a warning will be emitted.
+     */
+    private URI createURI(final String url) {
+        if (url != null) try {
+            return new URI(url);
+        } catch (URISyntaxException e) {
+            warning(e);
+        }
+        return null;
+    }
+
+    /**
      * Creates an {@code OnlineResource} element if the given URL is not null. Since ISO
19115
      * declares the URL as a mandatory attribute, this method will ignore all other attributes
      * if the given URL is null.
      *
-     * @param  url  the URL (mandatory - if {@code null}, no resource will be created).
+     * @param  url   the URL (mandatory - if {@code null}, no resource will be created).
      * @return the online resource, or {@code null} if the URL was null.
      */
     private OnlineResource createOnlineResource(final String url) {
-        if (url != null) try {
-            final DefaultOnlineResource resource = new DefaultOnlineResource(new URI(url));
-            resource.setProtocol("http");
+        final URI uri = createURI(url);
+        if (uri == null) {
+            return null;
+        }
+        final DefaultOnlineResource resource = new DefaultOnlineResource(uri);
+        final String protocol = uri.getScheme();
+        resource.setProtocol(protocol);
+        if ("http".equalsIgnoreCase(protocol) || "https".equalsIgnoreCase(protocol)) {
             resource.setApplicationProfile("web browser");
-            resource.setFunction(OnLineFunction.INFORMATION);
-            return resource;
-        } catch (URISyntaxException e) {
-            warning(e);
         }
-        return null;
+        resource.setFunction(OnLineFunction.INFORMATION);
+        return resource;
     }
 
     /**
@@ -891,7 +906,7 @@ split:  while ((start = CharSequences.sk
         final String id = (v.length == 1) ? trim((String) v[0]) : null;
         if (id != null && !id.equals(name)) {
             v = variable.getAttributeValues(ACDD.standard_name_vocabulary, false);
-            addBandIdentifier(v.length == 1 ? (String) v[0] : null, id);
+            addBandName(v.length == 1 ? (String) v[0] : null, id);
         }
         final String description = trim(variable.getDescription());
         if (description != null && !description.equals(name) && !description.equals(id))
{
@@ -908,6 +923,7 @@ split:  while ((start = CharSequences.sk
         v = variable.getAttributeValues(CDM.SCALE_FACTOR, true); if (v.length == 1) scale
 = ((Number) v[0]).doubleValue();
         v = variable.getAttributeValues(CDM.ADD_OFFSET,   true); if (v.length == 1) offset
= ((Number) v[0]).doubleValue();
         setTransferFunction(scale, offset);
+        addContentType(forCodeName(CoverageContentType.class, stringValue(ACDD.coverage_content_type)));
     }
 
     /**
@@ -1023,6 +1039,7 @@ split:  while ((start = CharSequences.sk
         }
         decoder.setSearchPath(searchPath);
         metadata.setMetadataStandards(Citations.ISO_19115);
+        addCompleteMetadata(createURI(stringValue(METADATA_LINK)));
         return metadata;
     }
 }

Modified: sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/MetadataBuilder.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/MetadataBuilder.java?rev=1812859&r1=1812858&r2=1812859&view=diff
==============================================================================
--- sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/MetadataBuilder.java
[UTF-8] (original)
+++ sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/MetadataBuilder.java
[UTF-8] Sat Oct 21 22:45:55 2017
@@ -24,6 +24,7 @@ import java.util.Collections;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
+import java.net.URI;
 import java.nio.charset.Charset;
 import javax.measure.Unit;
 import org.opengis.util.MemberName;
@@ -35,6 +36,7 @@ import org.opengis.metadata.citation.Rol
 import org.opengis.metadata.citation.DateType;
 import org.opengis.metadata.citation.Citation;
 import org.opengis.metadata.citation.CitationDate;
+import org.opengis.metadata.citation.OnLineFunction;
 import org.opengis.metadata.spatial.GCP;
 import org.opengis.metadata.spatial.Dimension;
 import org.opengis.metadata.spatial.DimensionNameType;
@@ -43,6 +45,7 @@ import org.opengis.metadata.spatial.Pixe
 import org.opengis.metadata.spatial.GeolocationInformation;
 import org.opengis.metadata.spatial.SpatialRepresentationType;
 import org.opengis.metadata.constraint.Restriction;
+import org.opengis.metadata.content.CoverageContentType;
 import org.opengis.metadata.content.TransferFunctionType;
 import org.opengis.metadata.maintenance.ScopeCode;
 import org.opengis.metadata.acquisition.Context;
@@ -85,6 +88,7 @@ import org.apache.sis.metadata.iso.citat
 import org.apache.sis.metadata.iso.citation.DefaultResponsibility;
 import org.apache.sis.metadata.iso.citation.DefaultIndividual;
 import org.apache.sis.metadata.iso.citation.DefaultOrganisation;
+import org.apache.sis.metadata.iso.citation.DefaultOnlineResource;
 import org.apache.sis.metadata.iso.constraint.DefaultLegalConstraints;
 import org.apache.sis.metadata.iso.identification.DefaultKeywords;
 import org.apache.sis.metadata.iso.identification.DefaultResolution;
@@ -2063,6 +2067,22 @@ parse:      for (int i = 0; i < length;)
     }
 
     /**
+     * Adds type of information represented in the cell.
+     * Storage location is:
+     *
+     * <ul>
+     *   <li>{@code metadata/contentInfo/attributeGroup/contentType}</li>
+     * </ul>
+     *
+     * @param  type  type of information represented in the cell, or {@code null} for no-operation.
+     */
+    public final void addContentType(final CoverageContentType type) {
+        if (type != null) {
+            attributeGroup().getContentTypes().add(type);
+        }
+    }
+
+    /**
      * Sets the name or number that uniquely identifies instances of bands of wavelengths
on which a sensor operates.
      * If a coverage contains more than one band, additional bands can be created by calling
      * {@link #newSampleDimension()} before to call this method.
@@ -2122,7 +2142,7 @@ parse:      for (int i = 0; i < length;)
      * @param  authority  identifies which controlled list of name is used, or {@code null}
if none.
      * @param  name       the band name, or {@code null} for no-operation.
      */
-    public final void addBandIdentifier(final CharSequence authority, String name) {
+    public final void addBandName(final CharSequence authority, String name) {
         if (name != null && !(name = name.trim()).isEmpty()) {
             addIfNotPresent(sampleDimension().getNames(), sharedIdentifier(authority, name));
         }
@@ -2583,6 +2603,25 @@ parse:      for (int i = 0; i < length;)
         }
     }
 
+    /**
+     * Adds a URL to a more complete description of the metadata.
+     *
+     * <ul>
+     *   <li>{@code metadata/metadataLinkage/linkage}
+     *     with {@code function} set to {@link OnLineFunction#COMPLETE_METADATA}</li>
+     * </ul>
+     *
+     * @param  link
+     */
+    public final void addCompleteMetadata(final URI link) {
+        if (link != null) {
+            final DefaultOnlineResource ln = new DefaultOnlineResource(link);
+            ln.setFunction(OnLineFunction.COMPLETE_METADATA);
+            ln.setProtocol(link.getScheme());
+            addIfNotPresent(metadata().getMetadataLinkages(), ln);
+        }
+    }
+
     /**
      * Returns the metadata (optionally as an unmodifiable object), or {@code null} if none.
      * If {@code freeze} is {@code true}, then the returned metadata instance can not be
modified.



Mime
View raw message