sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1771531 - in /sis/branches/JDK8/storage: sis-earth-observation/src/test/java/org/apache/sis/storage/earthobservation/ sis-geotiff/src/main/java/org/apache/sis/storage/geotiff/ sis-storage/src/main/java/org/apache/sis/internal/storage/
Date Sun, 27 Nov 2016 01:42:19 GMT
Author: desruisseaux
Date: Sun Nov 27 01:42:19 2016
New Revision: 1771531

URL: http://svn.apache.org/viewvc?rev=1771531&view=rev
Log:
Extract some metadata from GeoKeys.

Modified:
    sis/branches/JDK8/storage/sis-earth-observation/src/test/java/org/apache/sis/storage/earthobservation/LandsatReaderTest.java
    sis/branches/JDK8/storage/sis-geotiff/src/main/java/org/apache/sis/storage/geotiff/CRSBuilder.java
    sis/branches/JDK8/storage/sis-geotiff/src/main/java/org/apache/sis/storage/geotiff/GeoCodes.java
    sis/branches/JDK8/storage/sis-geotiff/src/main/java/org/apache/sis/storage/geotiff/GeoKeys.java
    sis/branches/JDK8/storage/sis-geotiff/src/main/java/org/apache/sis/storage/geotiff/ImageFileDirectory.java
    sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/MetadataBuilder.java

Modified: sis/branches/JDK8/storage/sis-earth-observation/src/test/java/org/apache/sis/storage/earthobservation/LandsatReaderTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-earth-observation/src/test/java/org/apache/sis/storage/earthobservation/LandsatReaderTest.java?rev=1771531&r1=1771530&r2=1771531&view=diff
==============================================================================
--- sis/branches/JDK8/storage/sis-earth-observation/src/test/java/org/apache/sis/storage/earthobservation/LandsatReaderTest.java
[UTF-8] (original)
+++ sis/branches/JDK8/storage/sis-earth-observation/src/test/java/org/apache/sis/storage/earthobservation/LandsatReaderTest.java
[UTF-8] Sun Nov 27 01:42:19 2016
@@ -103,7 +103,8 @@ public class LandsatReaderTest extends T
                 + "  │   ├─Axis dimension properties (2 of 2)\n"
                 + "  │   │   ├─Dimension name………………………………………………………
Line\n"
                 + "  │   │   └─Dimension size………………………………………………………
15500\n"
-                + "  │   └─Transformation parameter availability…… false\n"
+                + "  │   ├─Transformation parameter availability…… false\n"
+                + "  │   └─Check point availability………………………………………
false\n"
                 + "  ├─Spatial representation info (2 of 2)\n"
                 + "  │   ├─Number of dimensions…………………………………………………
2\n"
                 + "  │   ├─Axis dimension properties (1 of 2)\n"
@@ -112,7 +113,8 @@ public class LandsatReaderTest extends T
                 + "  │   ├─Axis dimension properties (2 of 2)\n"
                 + "  │   │   ├─Dimension name………………………………………………………
Line\n"
                 + "  │   │   └─Dimension size………………………………………………………
7800\n"
-                + "  │   └─Transformation parameter availability…… false\n"
+                + "  │   ├─Transformation parameter availability…… false\n"
+                + "  │   └─Check point availability………………………………………
false\n"
                 + "  ├─Reference system info…………………………………………………………
EPSG:WGS 84 / UTM zone 49N\n"
                 + "  ├─Identification info\n"
                 + "  │   ├─Citation\n"

Modified: sis/branches/JDK8/storage/sis-geotiff/src/main/java/org/apache/sis/storage/geotiff/CRSBuilder.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-geotiff/src/main/java/org/apache/sis/storage/geotiff/CRSBuilder.java?rev=1771531&r1=1771530&r2=1771531&view=diff
==============================================================================
--- sis/branches/JDK8/storage/sis-geotiff/src/main/java/org/apache/sis/storage/geotiff/CRSBuilder.java
[UTF-8] (original)
+++ sis/branches/JDK8/storage/sis-geotiff/src/main/java/org/apache/sis/storage/geotiff/CRSBuilder.java
[UTF-8] Sun Nov 27 01:42:19 2016
@@ -24,6 +24,8 @@ import java.util.logging.Level;
 import java.util.logging.LogRecord;
 import javax.measure.Unit;
 
+import org.opengis.metadata.spatial.CellGeometry;
+import org.opengis.metadata.spatial.PixelOrientation;
 import org.opengis.parameter.ParameterValueGroup;
 import org.opengis.referencing.IdentifiedObject;
 import org.opengis.referencing.crs.CRSFactory;
@@ -46,6 +48,7 @@ import org.opengis.util.FactoryException
 import org.opengis.util.NoSuchIdentifierException;
 
 import org.apache.sis.internal.geotiff.Resources;
+import org.apache.sis.internal.storage.MetadataBuilder;
 import org.apache.sis.internal.system.DefaultFactories;
 import org.apache.sis.internal.util.Constants;
 import org.apache.sis.math.Vector;
@@ -254,11 +257,12 @@ final class CRSBuilder {
     }
 
     /**
-     * Returns a {@link GeoKeys} value as an integer.
+     * Returns a {@link GeoKeys} value as an integer. This is used for fetching enumeration
values.
+     * The value returned by this method is typically one of the {@link GeoCodes} values.
      *
      * @param  key the GeoTIFF key for which to get a value.
-     * @return the integer value for the given key, or {@link Integer#MAX_VALUE} if the key
was not found
-     *         or can not be parsed.
+     * @return the integer value for the given key, or {@link GeoCodes#undefined}
+     *         if the key was not found or can not be parsed.
      */
     private int getAsInteger(final short key) {
         final Object value = geoKeys.get(key);
@@ -268,10 +272,10 @@ final class CRSBuilder {
             } else try {
                 return Integer.parseInt(value.toString());
             } catch (NumberFormatException e) {
-                warning(Resources.Keys.InvalidGeoValue_2, value, GeoKeys.name(key));
+                invalidValue(key, value);
             }
         }
-        return Integer.MIN_VALUE;
+        return GeoCodes.undefined;
     }
 
     /**
@@ -290,7 +294,7 @@ final class CRSBuilder {
             } else try {
                 return Double.parseDouble(value.toString());
             } catch (NumberFormatException e) {
-                warning(Resources.Keys.InvalidGeoValue_2, value, GeoKeys.name(key));
+                invalidValue(key, value);
             }
         }
         if (!mandatory) {
@@ -313,6 +317,13 @@ final class CRSBuilder {
         warning(Resources.Keys.MissingGeoValue_1, GeoKeys.name(key));
     }
 
+    /**
+     * Reports a warning about an invalid value for the given key.
+     */
+    private void invalidValue(final short key, final Object value) {
+        warning(Resources.Keys.InvalidGeoValue_2, GeoKeys.name(key), value);
+    }
+
 
     //---------------------------- geokeys parsing -----------------------------
 
@@ -467,8 +478,9 @@ final class CRSBuilder {
         /*
          * At this point we finished copying all GeoTIFF keys in CRSBuilder.geoKeys map.
          */
-        final int crsType = getAsInteger(GeoKeys.GTModelType);
+        final int crsType = getAsInteger(GeoKeys.ModelType);
         switch (crsType) {
+            case GeoCodes.undefined:           return null;
             case GeoCodes.ModelTypeProjected:  return createProjectedCRS();
             case GeoCodes.ModelTypeGeographic: return createGeographicCRS();
             case GeoCodes.ModelTypeGeocentric: // TODO
@@ -479,11 +491,39 @@ final class CRSBuilder {
         }
     }
 
-    //----------------------------- GEO UTILS ----------------------------------
     /**
-     * This code creates an <code>javax.Units.Unit</code> object out of the
-     * <code>ProjLinearUnitsGeoKey</code> and the
-     * <code>ProjLinearUnitSizeGeoKey</code>. The unit may either be
+     * Completes ISO 19115 metadata with some GeoTIFF values that are for documentation purposes.
+     * Those values do not participate directly to the construction of the Coordinate Reference
System objects.
+     *
+     * @param  metadata  the helper class where to write metadata values.
+     */
+    final void complete(final MetadataBuilder metadata) {
+        /*
+         * Whether the pixel value is thought of as filling the cell area or is considered
as point measurements at
+         * the vertices of the grid (not in the interior of a cell).  This is determined
by the value associated to
+         * GeoKeys.RasterType, which can be GeoCodes.RasterPixelIsArea or RasterPixelIsPoint.
+         */
+        CellGeometry     cg = null;
+        PixelOrientation po = null;
+        int code = getAsInteger(GeoKeys.RasterType);
+        switch (code) {
+            case GeoCodes.undefined: break;
+            case GeoCodes.RasterPixelIsArea:  cg = CellGeometry.AREA;  po = PixelOrientation.CENTER;
    break;
+            case GeoCodes.RasterPixelIsPoint: cg = CellGeometry.POINT; po = PixelOrientation.UPPER_LEFT;
break;
+            default: invalidValue(GeoKeys.RasterType, code); break;
+        }
+        metadata.setCellGeometry(cg);
+        metadata.setPointInPixel(po);
+    }
+
+
+    //-------------------------- geodetic components ---------------------------
+
+
+    /**
+     * Creates units of measurement from the
+     * <code>ProjLinearUnits</code> and the
+     * <code>ProjLinearUnitSize</code>. The unit may either be
      * specified as a standard EPSG recognized unit, or may be user defined.
      *
      * @param key
@@ -492,9 +532,9 @@ final class CRSBuilder {
      * @param def
      * @return <code>Unit</code> object representative of the tags in the file.
      * @throws IOException
-     *             if the<code>ProjLinearUnitsGeoKey</code> is not specified
+     *             if the<code>ProjLinearUnits</code> is not specified
      *             or if unit is user defined and
-     *             <code>ProjLinearUnitSizeGeoKey</code> is either not defined
+     *             <code>ProjLinearUnitSize</code> is either not defined
      *             or does not contain a number.
      */
     private Unit<?> createUnit(final short key, final short userDefinedKey, final Unit<?>
base, final Unit<?> def)

Modified: sis/branches/JDK8/storage/sis-geotiff/src/main/java/org/apache/sis/storage/geotiff/GeoCodes.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-geotiff/src/main/java/org/apache/sis/storage/geotiff/GeoCodes.java?rev=1771531&r1=1771530&r2=1771531&view=diff
==============================================================================
--- sis/branches/JDK8/storage/sis-geotiff/src/main/java/org/apache/sis/storage/geotiff/GeoCodes.java
[UTF-8] (original)
+++ sis/branches/JDK8/storage/sis-geotiff/src/main/java/org/apache/sis/storage/geotiff/GeoCodes.java
[UTF-8] Sun Nov 27 01:42:19 2016
@@ -18,9 +18,11 @@ package org.apache.sis.storage.geotiff;
 
 
 /**
- * Enumeration values associated to {@link GeoKeys}.
+ * Enumeration values associated to some {@link GeoKeys}. In this class, field names are
close to GeoTIFF code values.
+ * For that reason, many of those field names do not follow usual Java convention for constants.
  *
  * @author  Rémi Maréchal (Geomatys)
+ * @author  Martin Desruisseaux (Geomatys)
  * @since   0.8
  * @version 0.8
  * @module
@@ -32,6 +34,11 @@ final class GeoCodes {
     private GeoCodes() {
     }
 
+    /**
+     * The code value for undefined property.
+     */
+    public static final short undefined = 0;
+
     /*
      * 6.3.1.1 Model Type Codes
      *
@@ -49,4 +56,19 @@ final class GeoCodes {
     /** Projection Coordinate System         */ public static final short ModelTypeProjected
 = 1;
     /** Geographic latitude-longitude System */ public static final short ModelTypeGeographic
= 2;
     /** Geocentric (X,Y,Z) Coordinate System */ public static final short ModelTypeGeocentric
= 3;
+
+    /*
+     * 6.3.1.2 Raster Type Codes
+     *
+     * Ranges:
+     *   [            0]  =  undefined
+     *   [    1 …  1023]  =  Raster Type Codes (GeoTIFF Defined)
+     *   [ 1024 … 32766]  =  Reserved
+     *   [        32767]  =  user-defined
+     *   [32768 … 65535]  =  Private User Implementations
+     *
+     * Note: Use of "user-defined" or "undefined" raster codes is not recommended.
+     */
+    public static final short RasterPixelIsArea  = 1;
+    public static final short RasterPixelIsPoint = 2;
 }

Modified: sis/branches/JDK8/storage/sis-geotiff/src/main/java/org/apache/sis/storage/geotiff/GeoKeys.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-geotiff/src/main/java/org/apache/sis/storage/geotiff/GeoKeys.java?rev=1771531&r1=1771530&r2=1771531&view=diff
==============================================================================
--- sis/branches/JDK8/storage/sis-geotiff/src/main/java/org/apache/sis/storage/geotiff/GeoKeys.java
[UTF-8] (original)
+++ sis/branches/JDK8/storage/sis-geotiff/src/main/java/org/apache/sis/storage/geotiff/GeoKeys.java
[UTF-8] Sun Nov 27 01:42:19 2016
@@ -22,8 +22,10 @@ import org.opengis.referencing.operation
 
 
 /**
- * All Geographic Keys needed for building {@link CoordinateReferenceSystem} instances
- * and {@link MathTransform} "grid to CRS" from TIFF tags values.
+ * GeoTIFF keys associated to values needed for building {@link CoordinateReferenceSystem}
instances
+ * and {@link MathTransform} "grid to CRS". In this class, field names are close to GeoTIFF
key names
+ * with the {@code "GeoKey"} suffix omitted. For that reason, many of those field names do
not follow
+ * usual Java convention for constants.
  *
  * @author  Rémi Maréchal (Geomatys)
  * @since   0.8
@@ -38,11 +40,11 @@ final class GeoKeys {
     }
 
     // 6.2.1 GeoTIFF Configuration Keys
-    public static final short GTModelType           = 1024; /* Section 6.3.1.1 Codes */
-    public static final short GTRasterType          = 1025; /* Section 6.3.1.2 Codes */
-    public static final short GTCitation            = 1026; /* documentation */
+    /** Section 6.3.1.1 Codes */ public static final short ModelType  = 1024;
+    /** Section 6.3.1.2 Codes */ public static final short RasterType = 1025;
+    /** Documentation         */ public static final short Citation   = 1026;
 
-    public static final short GTUserDefined         = 32767;
+    public static final short UserDefined           = 32767;
     static final String GTUserDefined_String = "32767";
 
     // 6.2.2 Geographic CS Parameter Keys

Modified: sis/branches/JDK8/storage/sis-geotiff/src/main/java/org/apache/sis/storage/geotiff/ImageFileDirectory.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-geotiff/src/main/java/org/apache/sis/storage/geotiff/ImageFileDirectory.java?rev=1771531&r1=1771530&r2=1771531&view=diff
==============================================================================
--- sis/branches/JDK8/storage/sis-geotiff/src/main/java/org/apache/sis/storage/geotiff/ImageFileDirectory.java
[UTF-8] (original)
+++ sis/branches/JDK8/storage/sis-geotiff/src/main/java/org/apache/sis/storage/geotiff/ImageFileDirectory.java
[UTF-8] Sun Nov 27 01:42:19 2016
@@ -1027,7 +1027,12 @@ final class ImageFileDirectory {
          * ignore null values (a design choice because this pattern come very often).
          */
         if (geoKeyDirectory != null) {
-            metadata.add(new CRSBuilder(reader).build(geoKeyDirectory, numericGeoParameters,
asciiGeoParameters));
+            final CRSBuilder helper = new CRSBuilder(reader);
+            metadata.add(helper.build(geoKeyDirectory, numericGeoParameters, asciiGeoParameters));
+            helper.complete(metadata);
+            geoKeyDirectory      = null;            // Not needed anymore, so let GC do its
work.
+            numericGeoParameters = null;
+            asciiGeoParameters   = null;
         }
     }
 

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=1771531&r1=1771530&r2=1771531&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] Sun Nov 27 01:42:19 2016
@@ -30,6 +30,8 @@ import org.opengis.metadata.citation.Rol
 import org.opengis.metadata.citation.DateType;
 import org.opengis.metadata.spatial.Dimension;
 import org.opengis.metadata.spatial.DimensionNameType;
+import org.opengis.metadata.spatial.CellGeometry;
+import org.opengis.metadata.spatial.PixelOrientation;
 import org.opengis.metadata.constraint.Restriction;
 import org.opengis.metadata.maintenance.ScopeCode;
 import org.opengis.metadata.acquisition.Context;
@@ -46,7 +48,7 @@ import org.apache.sis.metadata.iso.exten
 import org.apache.sis.metadata.iso.extent.DefaultTemporalExtent;
 import org.apache.sis.metadata.iso.extent.DefaultGeographicBoundingBox;
 import org.apache.sis.metadata.iso.spatial.DefaultDimension;
-import org.apache.sis.metadata.iso.spatial.DefaultGridSpatialRepresentation;
+import org.apache.sis.metadata.iso.spatial.DefaultGeorectified;
 import org.apache.sis.metadata.iso.content.DefaultAttributeGroup;
 import org.apache.sis.metadata.iso.content.DefaultSampleDimension;
 import org.apache.sis.metadata.iso.content.DefaultCoverageDescription;
@@ -164,7 +166,7 @@ public class MetadataBuilder {
     /**
      * Information about the grid shape, or {@code null} if none.
      */
-    private DefaultGridSpatialRepresentation gridRepresentation;
+    private DefaultGeorectified gridRepresentation;
 
     /**
      * Information about the content of a grid data cell, or {@code null} if none.
@@ -543,9 +545,9 @@ public class MetadataBuilder {
      *
      * @return the grid representation object (never {@code null}).
      */
-    private DefaultGridSpatialRepresentation gridRepresentation() {
+    private DefaultGeorectified gridRepresentation() {
         if (gridRepresentation == null) {
-            gridRepresentation = new DefaultGridSpatialRepresentation();
+            gridRepresentation = new DefaultGeorectified();
         }
         return gridRepresentation;
     }
@@ -1419,6 +1421,34 @@ parse:      for (int i = 0; i < length;)
         }
     }
 
+    /**
+     * Sets identification of grid data as point or cell.
+     * Storage location is:
+     *
+     * <pre>metadata/spatialRepresentationInfo/cellGeometry</pre>
+     *
+     * @param  value   whether the data represent point or area, or {@code null} if unknown.
+     */
+    public final void setCellGeometry(final CellGeometry value) {
+        if (value != null) {
+            gridRepresentation().setCellGeometry(value);
+        }
+    }
+
+    /**
+     * Sets the point in a pixel corresponding to the Earth location of the pixel.
+     * Storage location is:
+     *
+     * <pre>metadata/spatialRepresentationInfo/pointInPixel</pre>
+     *
+     * @param  value   whether the data represent point or area, or {@code null} if unknown.
+     */
+    public final void setPointInPixel(final PixelOrientation value) {
+        if (value != null) {
+            gridRepresentation().setPointInPixel(value);
+        }
+    }
+
     /**
      * Returns the axis at the given dimension index. All previous dimensions are created
if needed.
      *



Mime
View raw message