sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1759474 [2/2] - in /sis/branches/JDK8/storage: sis-earth-observation/src/main/java/org/apache/sis/storage/earthobservation/ sis-earth-observation/src/main/java/org/apache/sis/storage/earthobservation/doc-files/ sis-earth-observation/src/te...
Date Tue, 06 Sep 2016 17:39:55 GMT
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=1759474&r1=1759473&r2=1759474&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] Tue Sep  6 17:39:55 2016
@@ -31,6 +31,7 @@ import org.junit.Test;
 
 import static org.apache.sis.test.Assert.*;
 import static org.apache.sis.test.TestUtilities.formatNameAndValue;
+import static org.apache.sis.storage.earthobservation.LandsatReader.DIM;
 
 
 /**
@@ -54,6 +55,21 @@ public class LandsatReaderTest extends T
     }
 
     /**
+     * Verifies the value of the {@link LandsatReader#BAND_GROUPS} mask.
+     */
+    @Test
+    public void verifyBandGroupsMask() {
+        final int[] PANCHROMATIC = {8};
+        final int[] REFLECTIVE   = {1, 2, 3, 4, 5, 6, 7, 9};
+        final int[] THERMAL      = {10, 11};
+        long mask = 0;
+        for (int i=0; i < PANCHROMATIC.length; i++) mask |= (LandsatReader.PANCHROMATIC/DIM << 2*(PANCHROMATIC[i] - 1));
+        for (int i=0; i <   REFLECTIVE.length; i++) mask |= (LandsatReader.REFLECTIVE/DIM   <<   2*(REFLECTIVE[i] - 1));
+        for (int i=0; i <      THERMAL.length; i++) mask |= (LandsatReader.THERMAL/DIM      <<      2*(THERMAL[i] - 1));
+        assertEquals("BAND_GROUPS", mask, LandsatReader.BAND_GROUPS);
+    }
+
+    /**
      * Tests {@link LandsatReader#read()}.
      *
      * <p><b>NOTE FOR MAINTAINER:</b> if the result of this test changes, consider updating
@@ -76,200 +92,231 @@ public class LandsatReaderTest extends T
         final String text = formatNameAndValue(DefaultMetadata.castOrCopy(actual).asTreeTable());
         assertMultilinesEquals(
                 "Metadata\n"
-                + "  ├─Language…………………………………………………………………………… en\n"
+                + "  ├─Language…………………………………………………………………………………………… en\n"
+                + "  ├─Spatial representation info (1 of 3)\n"
+                + "  │   ├─Number of dimensions………………………………………………… 2\n"
+                + "  │   ├─Axis dimension properties (1 of 2)\n"
+                + "  │   │   ├─Dimension name……………………………………………………… Sample\n"
+                + "  │   │   └─Dimension size……………………………………………………… 15000\n"
+                + "  │   ├─Axis dimension properties (2 of 2)\n"
+                + "  │   │   ├─Dimension name……………………………………………………… Line\n"
+                + "  │   │   └─Dimension size……………………………………………………… 15500\n"
+                + "  │   └─Transformation parameter availability…… false\n"
+                + "  ├─Spatial representation info (2 of 3)\n"
+                + "  │   ├─Number of dimensions………………………………………………… 2\n"
+                + "  │   ├─Axis dimension properties (1 of 2)\n"
+                + "  │   │   ├─Dimension name……………………………………………………… Sample\n"
+                + "  │   │   └─Dimension size……………………………………………………… 7600\n"
+                + "  │   ├─Axis dimension properties (2 of 2)\n"
+                + "  │   │   ├─Dimension name……………………………………………………… Line\n"
+                + "  │   │   └─Dimension size……………………………………………………… 7800\n"
+                + "  │   └─Transformation parameter availability…… false\n"
+                + "  ├─Spatial representation info (3 of 3)\n"
+                + "  │   ├─Number of dimensions………………………………………………… 2\n"
+                + "  │   ├─Axis dimension properties (1 of 2)\n"
+                + "  │   │   ├─Dimension name……………………………………………………… Sample\n"
+                + "  │   │   └─Dimension size……………………………………………………… 7600\n"
+                + "  │   ├─Axis dimension properties (2 of 2)\n"
+                + "  │   │   ├─Dimension name……………………………………………………… Line\n"
+                + "  │   │   └─Dimension size……………………………………………………… 7800\n"
+                + "  │   └─Transformation parameter availability…… false\n"
                 + "  ├─Identification info\n"
                 + "  │   ├─Citation\n"
                 + "  │   │   ├─Date\n"
-                + "  │   │   │   ├─Date……………………………………………………… 2016-06-27 16:48:12\n"
-                + "  │   │   │   └─Date type………………………………………… Creation\n"
+                + "  │   │   │   ├─Date……………………………………………………………………… 2016-06-27 16:48:12\n"
+                + "  │   │   │   └─Date type………………………………………………………… Creation\n"
                 + "  │   │   └─Identifier\n"
-                + "  │   │       └─Code……………………………………………………… LandsatTest\n"
-                + "  │   ├─Credit……………………………………………………………………… Derived from U.S. Geological Survey data\n"
+                + "  │   │       └─Code……………………………………………………………………… LandsatTest\n"
+                + "  │   ├─Credit……………………………………………………………………………………… Derived from U.S. Geological Survey data\n"
                 + "  │   ├─Resource format\n"
                 + "  │   │   └─Format specification citation\n"
-                + "  │   │       ├─Title…………………………………………………… GeoTIFF Coverage Encoding Profile\n"
-                + "  │   │       └─Alternate title………………………… GEOTIFF\n"
+                + "  │   │       ├─Title…………………………………………………………………… GeoTIFF Coverage Encoding Profile\n"
+                + "  │   │       └─Alternate title………………………………………… GEOTIFF\n"
                 + "  │   ├─Spatial resolution (1 of 2)\n"
-                + "  │   │   └─Distance……………………………………………………… 15.0\n"
+                + "  │   │   └─Distance……………………………………………………………………… 15.0\n"
                 + "  │   ├─Spatial resolution (2 of 2)\n"
-                + "  │   │   └─Distance……………………………………………………… 30.0\n"
+                + "  │   │   └─Distance……………………………………………………………………… 30.0\n"
                 + "  │   └─Extent\n"
                 + "  │       └─Geographic element\n"
-                + "  │           ├─West bound longitude…………… 108°20′24″E\n"
-                + "  │           ├─East bound longitude…………… 110°26′24″E\n"
-                + "  │           ├─South bound latitude…………… 10°30′N\n"
-                + "  │           ├─North bound latitude…………… 12°37′12″N\n"
-                + "  │           └─Extent type code……………………… true\n"
+                + "  │           ├─West bound longitude…………………………… 108°20′24″E\n"
+                + "  │           ├─East bound longitude…………………………… 110°26′24″E\n"
+                + "  │           ├─South bound latitude…………………………… 10°30′N\n"
+                + "  │           ├─North bound latitude…………………………… 12°37′12″N\n"
+                + "  │           └─Extent type code……………………………………… true\n"
                 + "  ├─Content info\n"
-                + "  │   ├─Illumination elevation angle…………… 58.8\n"
-                + "  │   ├─Illumination azimuth angle………………… 116.9\n"
-                + "  │   ├─Cloud cover percentage…………………………… 8.3\n"
-                + "  │   └─Attribute group\n"
-                + "  │       ├─Content type…………………………………………… Physical measurement\n"
-                + "  │       ├─Attribute (1 of 11)\n"
-                + "  │       │   ├─Max value………………………………………… 65535.0\n"
-                + "  │       │   ├─Min value………………………………………… 1.0\n"
-                + "  │       │   ├─Peak response……………………………… 433.0\n"
-                + "  │       │   ├─Scale factor………………………………… 0.0127\n"
-                + "  │       │   ├─Offset………………………………………………… -63.6\n"
-                + "  │       │   ├─Transfer function type……… Linear\n"
-                + "  │       │   ├─Bound units…………………………………… nm\n"
-                + "  │       │   ├─Description…………………………………… Coastal Aerosol\n"
-                + "  │       │   └─Name\n"
-                + "  │       │       └─Code…………………………………………… TestImage_B1.TIF\n"
-                + "  │       ├─Attribute (2 of 11)\n"
-                + "  │       │   ├─Max value………………………………………… 65535.0\n"
-                + "  │       │   ├─Min value………………………………………… 1.0\n"
-                + "  │       │   ├─Peak response……………………………… 482.0\n"
-                + "  │       │   ├─Scale factor………………………………… 0.013\n"
-                + "  │       │   ├─Offset………………………………………………… -65.1\n"
-                + "  │       │   ├─Transfer function type……… Linear\n"
-                + "  │       │   ├─Bound units…………………………………… nm\n"
-                + "  │       │   ├─Description…………………………………… Blue\n"
-                + "  │       │   └─Name\n"
-                + "  │       │       └─Code…………………………………………… TestImage_B2.TIF\n"
-                + "  │       ├─Attribute (3 of 11)\n"
-                + "  │       │   ├─Max value………………………………………… 65535.0\n"
-                + "  │       │   ├─Min value………………………………………… 1.0\n"
-                + "  │       │   ├─Peak response……………………………… 562.0\n"
-                + "  │       │   ├─Scale factor………………………………… 0.012\n"
-                + "  │       │   ├─Offset………………………………………………… -60.0\n"
-                + "  │       │   ├─Transfer function type……… Linear\n"
-                + "  │       │   ├─Bound units…………………………………… nm\n"
-                + "  │       │   ├─Description…………………………………… Green\n"
-                + "  │       │   └─Name\n"
-                + "  │       │       └─Code…………………………………………… TestImage_B3.TIF\n"
-                + "  │       ├─Attribute (4 of 11)\n"
-                + "  │       │   ├─Max value………………………………………… 65535.0\n"
-                + "  │       │   ├─Min value………………………………………… 1.0\n"
-                + "  │       │   ├─Peak response……………………………… 655.0\n"
-                + "  │       │   ├─Scale factor………………………………… 0.0101\n"
-                + "  │       │   ├─Offset………………………………………………… -50.6\n"
-                + "  │       │   ├─Transfer function type……… Linear\n"
-                + "  │       │   ├─Bound units…………………………………… nm\n"
-                + "  │       │   ├─Description…………………………………… Red\n"
-                + "  │       │   └─Name\n"
-                + "  │       │       └─Code…………………………………………… TestImage_B4.TIF\n"
-                + "  │       ├─Attribute (5 of 11)\n"
-                + "  │       │   ├─Max value………………………………………… 65535.0\n"
-                + "  │       │   ├─Min value………………………………………… 1.0\n"
-                + "  │       │   ├─Peak response……………………………… 865.0\n"
-                + "  │       │   ├─Scale factor………………………………… 0.00619\n"
-                + "  │       │   ├─Offset………………………………………………… -31.0\n"
-                + "  │       │   ├─Transfer function type……… Linear\n"
-                + "  │       │   ├─Bound units…………………………………… nm\n"
-                + "  │       │   ├─Description…………………………………… Near-Infrared\n"
-                + "  │       │   └─Name\n"
-                + "  │       │       └─Code…………………………………………… TestImage_B5.TIF\n"
-                + "  │       ├─Attribute (6 of 11)\n"
-                + "  │       │   ├─Max value………………………………………… 65535.0\n"
-                + "  │       │   ├─Min value………………………………………… 1.0\n"
-                + "  │       │   ├─Peak response……………………………… 1610.0\n"
-                + "  │       │   ├─Scale factor………………………………… 0.00154\n"
-                + "  │       │   ├─Offset………………………………………………… -7.7\n"
-                + "  │       │   ├─Transfer function type……… Linear\n"
-                + "  │       │   ├─Bound units…………………………………… nm\n"
-                + "  │       │   ├─Description…………………………………… Short Wavelength Infrared (SWIR) 1\n"
-                + "  │       │   └─Name\n"
-                + "  │       │       └─Code…………………………………………… TestImage_B6.TIF\n"
-                + "  │       ├─Attribute (7 of 11)\n"
-                + "  │       │   ├─Max value………………………………………… 65535.0\n"
-                + "  │       │   ├─Min value………………………………………… 1.0\n"
-                + "  │       │   ├─Peak response……………………………… 2200.0\n"
-                + "  │       │   ├─Scale factor………………………………… 5.19E-4\n"
-                + "  │       │   ├─Offset………………………………………………… -2.6\n"
-                + "  │       │   ├─Transfer function type……… Linear\n"
-                + "  │       │   ├─Bound units…………………………………… nm\n"
-                + "  │       │   ├─Description…………………………………… Short Wavelength Infrared (SWIR) 2\n"
-                + "  │       │   └─Name\n"
-                + "  │       │       └─Code…………………………………………… TestImage_B7.TIF\n"
-                + "  │       ├─Attribute (8 of 11)\n"
-                + "  │       │   ├─Max value………………………………………… 65535.0\n"
-                + "  │       │   ├─Min value………………………………………… 1.0\n"
-                + "  │       │   ├─Peak response……………………………… 590.0\n"
-                + "  │       │   ├─Scale factor………………………………… 0.0115\n"
-                + "  │       │   ├─Offset………………………………………………… -57.3\n"
-                + "  │       │   ├─Transfer function type……… Linear\n"
-                + "  │       │   ├─Bound units…………………………………… nm\n"
-                + "  │       │   ├─Description…………………………………… Panchromatic\n"
-                + "  │       │   └─Name\n"
-                + "  │       │       └─Code…………………………………………… TestImage_B8.TIF\n"
-                + "  │       ├─Attribute (9 of 11)\n"
-                + "  │       │   ├─Max value………………………………………… 65535.0\n"
-                + "  │       │   ├─Min value………………………………………… 1.0\n"
-                + "  │       │   ├─Peak response……………………………… 1375.0\n"
-                + "  │       │   ├─Scale factor………………………………… 0.00242\n"
-                + "  │       │   ├─Offset………………………………………………… -12.1\n"
-                + "  │       │   ├─Transfer function type……… Linear\n"
-                + "  │       │   ├─Bound units…………………………………… nm\n"
-                + "  │       │   ├─Description…………………………………… Cirrus\n"
-                + "  │       │   └─Name\n"
-                + "  │       │       └─Code…………………………………………… TestImage_B9.TIF\n"
-                + "  │       ├─Attribute (10 of 11)\n"
-                + "  │       │   ├─Max value………………………………………… 65535.0\n"
-                + "  │       │   ├─Min value………………………………………… 1.0\n"
-                + "  │       │   ├─Peak response……………………………… 10800.0\n"
-                + "  │       │   ├─Scale factor………………………………… 3.34E-4\n"
-                + "  │       │   ├─Offset………………………………………………… 0.1\n"
-                + "  │       │   ├─Transfer function type……… Linear\n"
-                + "  │       │   ├─Bound units…………………………………… nm\n"
-                + "  │       │   ├─Description…………………………………… Thermal Infrared Sensor (TIRS) 1\n"
+                + "  │   ├─Illumination elevation angle…………………………… 58.8\n"
+                + "  │   ├─Illumination azimuth angle………………………………… 116.9\n"
+                + "  │   ├─Cloud cover percentage…………………………………………… 8.3\n"
+                + "  │   ├─Attribute group (1 of 3)\n"
+                + "  │   │   ├─Content type…………………………………………………………… Physical measurement\n"
+                + "  │   │   ├─Attribute (1 of 8)\n"
+                + "  │   │   │   ├─Max value………………………………………………………… 65535.0\n"
+                + "  │   │   │   ├─Min value………………………………………………………… 1.0\n"
+                + "  │   │   │   ├─Peak response……………………………………………… 433.0\n"
+                + "  │   │   │   ├─Scale factor………………………………………………… 0.0127\n"
+                + "  │   │   │   ├─Offset………………………………………………………………… -63.6\n"
+                + "  │   │   │   ├─Transfer function type……………………… Linear\n"
+                + "  │   │   │   ├─Bound units…………………………………………………… nm\n"
+                + "  │   │   │   ├─Description…………………………………………………… Coastal Aerosol\n"
+                + "  │   │   │   └─Name\n"
+                + "  │   │   │       └─Code…………………………………………………………… TestImage_B1.TIF\n"
+                + "  │   │   ├─Attribute (2 of 8)\n"
+                + "  │   │   │   ├─Max value………………………………………………………… 65535.0\n"
+                + "  │   │   │   ├─Min value………………………………………………………… 1.0\n"
+                + "  │   │   │   ├─Peak response……………………………………………… 482.0\n"
+                + "  │   │   │   ├─Scale factor………………………………………………… 0.013\n"
+                + "  │   │   │   ├─Offset………………………………………………………………… -65.1\n"
+                + "  │   │   │   ├─Transfer function type……………………… Linear\n"
+                + "  │   │   │   ├─Bound units…………………………………………………… nm\n"
+                + "  │   │   │   ├─Description…………………………………………………… Blue\n"
+                + "  │   │   │   └─Name\n"
+                + "  │   │   │       └─Code…………………………………………………………… TestImage_B2.TIF\n"
+                + "  │   │   ├─Attribute (3 of 8)\n"
+                + "  │   │   │   ├─Max value………………………………………………………… 65535.0\n"
+                + "  │   │   │   ├─Min value………………………………………………………… 1.0\n"
+                + "  │   │   │   ├─Peak response……………………………………………… 562.0\n"
+                + "  │   │   │   ├─Scale factor………………………………………………… 0.012\n"
+                + "  │   │   │   ├─Offset………………………………………………………………… -60.0\n"
+                + "  │   │   │   ├─Transfer function type……………………… Linear\n"
+                + "  │   │   │   ├─Bound units…………………………………………………… nm\n"
+                + "  │   │   │   ├─Description…………………………………………………… Green\n"
+                + "  │   │   │   └─Name\n"
+                + "  │   │   │       └─Code…………………………………………………………… TestImage_B3.TIF\n"
+                + "  │   │   ├─Attribute (4 of 8)\n"
+                + "  │   │   │   ├─Max value………………………………………………………… 65535.0\n"
+                + "  │   │   │   ├─Min value………………………………………………………… 1.0\n"
+                + "  │   │   │   ├─Peak response……………………………………………… 655.0\n"
+                + "  │   │   │   ├─Scale factor………………………………………………… 0.0101\n"
+                + "  │   │   │   ├─Offset………………………………………………………………… -50.6\n"
+                + "  │   │   │   ├─Transfer function type……………………… Linear\n"
+                + "  │   │   │   ├─Bound units…………………………………………………… nm\n"
+                + "  │   │   │   ├─Description…………………………………………………… Red\n"
+                + "  │   │   │   └─Name\n"
+                + "  │   │   │       └─Code…………………………………………………………… TestImage_B4.TIF\n"
+                + "  │   │   ├─Attribute (5 of 8)\n"
+                + "  │   │   │   ├─Max value………………………………………………………… 65535.0\n"
+                + "  │   │   │   ├─Min value………………………………………………………… 1.0\n"
+                + "  │   │   │   ├─Peak response……………………………………………… 865.0\n"
+                + "  │   │   │   ├─Scale factor………………………………………………… 0.00619\n"
+                + "  │   │   │   ├─Offset………………………………………………………………… -31.0\n"
+                + "  │   │   │   ├─Transfer function type……………………… Linear\n"
+                + "  │   │   │   ├─Bound units…………………………………………………… nm\n"
+                + "  │   │   │   ├─Description…………………………………………………… Near-Infrared\n"
+                + "  │   │   │   └─Name\n"
+                + "  │   │   │       └─Code…………………………………………………………… TestImage_B5.TIF\n"
+                + "  │   │   ├─Attribute (6 of 8)\n"
+                + "  │   │   │   ├─Max value………………………………………………………… 65535.0\n"
+                + "  │   │   │   ├─Min value………………………………………………………… 1.0\n"
+                + "  │   │   │   ├─Peak response……………………………………………… 1610.0\n"
+                + "  │   │   │   ├─Scale factor………………………………………………… 0.00154\n"
+                + "  │   │   │   ├─Offset………………………………………………………………… -7.7\n"
+                + "  │   │   │   ├─Transfer function type……………………… Linear\n"
+                + "  │   │   │   ├─Bound units…………………………………………………… nm\n"
+                + "  │   │   │   ├─Description…………………………………………………… Short Wavelength Infrared (SWIR) 1\n"
+                + "  │   │   │   └─Name\n"
+                + "  │   │   │       └─Code…………………………………………………………… TestImage_B6.TIF\n"
+                + "  │   │   ├─Attribute (7 of 8)\n"
+                + "  │   │   │   ├─Max value………………………………………………………… 65535.0\n"
+                + "  │   │   │   ├─Min value………………………………………………………… 1.0\n"
+                + "  │   │   │   ├─Peak response……………………………………………… 2200.0\n"
+                + "  │   │   │   ├─Scale factor………………………………………………… 5.19E-4\n"
+                + "  │   │   │   ├─Offset………………………………………………………………… -2.6\n"
+                + "  │   │   │   ├─Transfer function type……………………… Linear\n"
+                + "  │   │   │   ├─Bound units…………………………………………………… nm\n"
+                + "  │   │   │   ├─Description…………………………………………………… Short Wavelength Infrared (SWIR) 2\n"
+                + "  │   │   │   └─Name\n"
+                + "  │   │   │       └─Code…………………………………………………………… TestImage_B7.TIF\n"
+                + "  │   │   └─Attribute (8 of 8)\n"
+                + "  │   │       ├─Max value………………………………………………………… 65535.0\n"
+                + "  │   │       ├─Min value………………………………………………………… 1.0\n"
+                + "  │   │       ├─Peak response……………………………………………… 1375.0\n"
+                + "  │   │       ├─Scale factor………………………………………………… 0.00242\n"
+                + "  │   │       ├─Offset………………………………………………………………… -12.1\n"
+                + "  │   │       ├─Transfer function type……………………… Linear\n"
+                + "  │   │       ├─Bound units…………………………………………………… nm\n"
+                + "  │   │       ├─Description…………………………………………………… Cirrus\n"
+                + "  │   │       └─Name\n"
+                + "  │   │           └─Code…………………………………………………………… TestImage_B9.TIF\n"
+                + "  │   ├─Attribute group (2 of 3)\n"
+                + "  │   │   ├─Content type…………………………………………………………… Physical measurement\n"
+                + "  │   │   └─Attribute\n"
+                + "  │   │       ├─Max value………………………………………………………… 65535.0\n"
+                + "  │   │       ├─Min value………………………………………………………… 1.0\n"
+                + "  │   │       ├─Peak response……………………………………………… 590.0\n"
+                + "  │   │       ├─Scale factor………………………………………………… 0.0115\n"
+                + "  │   │       ├─Offset………………………………………………………………… -57.3\n"
+                + "  │   │       ├─Transfer function type……………………… Linear\n"
+                + "  │   │       ├─Bound units…………………………………………………… nm\n"
+                + "  │   │       ├─Description…………………………………………………… Panchromatic\n"
+                + "  │   │       └─Name\n"
+                + "  │   │           └─Code…………………………………………………………… TestImage_B8.TIF\n"
+                + "  │   └─Attribute group (3 of 3)\n"
+                + "  │       ├─Content type…………………………………………………………… Physical measurement\n"
+                + "  │       ├─Attribute (1 of 2)\n"
+                + "  │       │   ├─Max value………………………………………………………… 65535.0\n"
+                + "  │       │   ├─Min value………………………………………………………… 1.0\n"
+                + "  │       │   ├─Peak response……………………………………………… 10800.0\n"
+                + "  │       │   ├─Scale factor………………………………………………… 3.34E-4\n"
+                + "  │       │   ├─Offset………………………………………………………………… 0.1\n"
+                + "  │       │   ├─Transfer function type……………………… Linear\n"
+                + "  │       │   ├─Bound units…………………………………………………… nm\n"
+                + "  │       │   ├─Description…………………………………………………… Thermal Infrared Sensor (TIRS) 1\n"
                 + "  │       │   └─Name\n"
-                + "  │       │       └─Code…………………………………………… TestImage_B10.TIF\n"
-                + "  │       └─Attribute (11 of 11)\n"
-                + "  │           ├─Max value………………………………………… 65535.0\n"
-                + "  │           ├─Min value………………………………………… 1.0\n"
-                + "  │           ├─Peak response……………………………… 12000.0\n"
-                + "  │           ├─Scale factor………………………………… 3.34E-4\n"
-                + "  │           ├─Offset………………………………………………… 0.1\n"
-                + "  │           ├─Transfer function type……… Linear\n"
-                + "  │           ├─Bound units…………………………………… nm\n"
-                + "  │           ├─Description…………………………………… Thermal Infrared Sensor (TIRS) 2\n"
+                + "  │       │       └─Code…………………………………………………………… TestImage_B10.TIF\n"
+                + "  │       └─Attribute (2 of 2)\n"
+                + "  │           ├─Max value………………………………………………………… 65535.0\n"
+                + "  │           ├─Min value………………………………………………………… 1.0\n"
+                + "  │           ├─Peak response……………………………………………… 12000.0\n"
+                + "  │           ├─Scale factor………………………………………………… 3.34E-4\n"
+                + "  │           ├─Offset………………………………………………………………… 0.1\n"
+                + "  │           ├─Transfer function type……………………… Linear\n"
+                + "  │           ├─Bound units…………………………………………………… nm\n"
+                + "  │           ├─Description…………………………………………………… Thermal Infrared Sensor (TIRS) 2\n"
                 + "  │           └─Name\n"
-                + "  │               └─Code…………………………………………… TestImage_B11.TIF\n"
+                + "  │               └─Code…………………………………………………………… TestImage_B11.TIF\n"
                 + "  ├─Acquisition information\n"
                 + "  │   ├─Operation\n"
-                + "  │   │   ├─Status…………………………………………………………… Completed\n"
-                + "  │   │   ├─Type………………………………………………………………… Real\n"
+                + "  │   │   ├─Status…………………………………………………………………………… Completed\n"
+                + "  │   │   ├─Type………………………………………………………………………………… Real\n"
                 + "  │   │   └─Significant event\n"
-                + "  │   │       ├─Context……………………………………………… Acquisition\n"
-                + "  │   │       └─Time……………………………………………………… 2016-06-26 03:02:01\n"
+                + "  │   │       ├─Context……………………………………………………………… Acquisition\n"
+                + "  │   │       └─Time……………………………………………………………………… 2016-06-26 03:02:01\n"
                 + "  │   └─Platform\n"
                 + "  │       ├─Identifier\n"
-                + "  │       │   └─Code……………………………………………………… Pseudo LANDSAT\n"
+                + "  │       │   └─Code……………………………………………………………………… Pseudo LANDSAT\n"
                 + "  │       └─Instrument\n"
                 + "  │           └─Identifier\n"
-                + "  │               └─Code…………………………………………… Pseudo TIRS\n"
+                + "  │               └─Code…………………………………………………………… Pseudo TIRS\n"
                 + "  ├─Date info\n"
-                + "  │   ├─Date…………………………………………………………………………… 2016-06-27 16:48:12\n"
-                + "  │   └─Date type……………………………………………………………… Creation\n"
+                + "  │   ├─Date…………………………………………………………………………………………… 2016-06-27 16:48:12\n"
+                + "  │   └─Date type……………………………………………………………………………… Creation\n"
                 + "  ├─Metadata scope\n"
-                + "  │   └─Resource scope………………………………………………… Dataset\n"
+                + "  │   └─Resource scope………………………………………………………………… Dataset\n"
                 + "  ├─Metadata identifier\n"
-                + "  │   └─Code…………………………………………………………………………… LandsatTest\n"
+                + "  │   └─Code…………………………………………………………………………………………… LandsatTest\n"
                 + "  ├─Metadata standard (1 of 2)\n"
-                + "  │   ├─Title………………………………………………………………………… Geographic Information — Metadata Part 1: Fundamentals\n"
+                + "  │   ├─Title………………………………………………………………………………………… Geographic Information — Metadata Part 1: Fundamentals\n"
                 + "  │   ├─Cited responsible party\n"
                 + "  │   │   ├─Party\n"
-                + "  │   │   │   └─Name……………………………………………………… International Organization for Standardization\n"
-                + "  │   │   └─Role………………………………………………………………… Principal investigator\n"
-                + "  │   ├─Edition…………………………………………………………………… ISO 19115-1:2014(E)\n"
+                + "  │   │   │   └─Name……………………………………………………………………… International Organization for Standardization\n"
+                + "  │   │   └─Role………………………………………………………………………………… Principal investigator\n"
+                + "  │   ├─Edition…………………………………………………………………………………… ISO 19115-1:2014(E)\n"
                 + "  │   ├─Identifier\n"
-                + "  │   │   ├─Code………………………………………………………………… 19115-1\n"
-                + "  │   │   ├─Code space………………………………………………… ISO\n"
-                + "  │   │   └─Version………………………………………………………… 2014(E)\n"
-                + "  │   └─Presentation form………………………………………… Document digital\n"
+                + "  │   │   ├─Code………………………………………………………………………………… 19115-1\n"
+                + "  │   │   ├─Code space………………………………………………………………… ISO\n"
+                + "  │   │   └─Version………………………………………………………………………… 2014(E)\n"
+                + "  │   └─Presentation form………………………………………………………… Document digital\n"
                 + "  └─Metadata standard (2 of 2)\n"
-                + "      ├─Title………………………………………………………………………… Geographic Information — Metadata Part 2: Extensions for imagery and gridded data\n"
+                + "      ├─Title………………………………………………………………………………………… Geographic Information — Metadata Part 2: Extensions for imagery and gridded data\n"
                 + "      ├─Cited responsible party\n"
                 + "      │   ├─Party\n"
-                + "      │   │   └─Name……………………………………………………… International Organization for Standardization\n"
-                + "      │   └─Role………………………………………………………………… Principal investigator\n"
-                + "      ├─Edition…………………………………………………………………… ISO 19115-2:2009(E)\n"
+                + "      │   │   └─Name……………………………………………………………………… International Organization for Standardization\n"
+                + "      │   └─Role………………………………………………………………………………… Principal investigator\n"
+                + "      ├─Edition…………………………………………………………………………………… ISO 19115-2:2009(E)\n"
                 + "      ├─Identifier\n"
-                + "      │   ├─Code………………………………………………………………… 19115-2\n"
-                + "      │   ├─Code space………………………………………………… ISO\n"
-                + "      │   └─Version………………………………………………………… 2009(E)\n"
-                + "      └─Presentation form………………………………………… Document digital\n", text);
+                + "      │   ├─Code………………………………………………………………………………… 19115-2\n"
+                + "      │   ├─Code space………………………………………………………………… ISO\n"
+                + "      │   └─Version………………………………………………………………………… 2009(E)\n"
+                + "      └─Presentation form………………………………………………………… Document digital\n", text);
     }
 }

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=1759474&r1=1759473&r2=1759474&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] Tue Sep  6 17:39:55 2016
@@ -21,12 +21,15 @@ import java.util.Locale;
 import java.util.Collection;
 import java.util.Collections;
 import java.util.HashMap;
+import java.util.List;
 import java.util.Map;
 import java.nio.charset.Charset;
 import org.opengis.util.InternationalString;
 import org.opengis.metadata.Identifier;
 import org.opengis.metadata.citation.Role;
 import org.opengis.metadata.citation.DateType;
+import org.opengis.metadata.spatial.Dimension;
+import org.opengis.metadata.spatial.DimensionNameType;
 import org.opengis.metadata.constraint.Restriction;
 import org.opengis.metadata.maintenance.ScopeCode;
 import org.opengis.metadata.acquisition.Context;
@@ -42,6 +45,8 @@ import org.apache.sis.metadata.iso.Defau
 import org.apache.sis.metadata.iso.extent.DefaultExtent;
 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.content.DefaultAttributeGroup;
 import org.apache.sis.metadata.iso.content.DefaultSampleDimension;
 import org.apache.sis.metadata.iso.content.DefaultCoverageDescription;
@@ -150,6 +155,11 @@ public class MetadataBuilder {
     private DefaultPlatform platform;
 
     /**
+     * Information about the grid shape, or {@code null} if none.
+     */
+    private DefaultGridSpatialRepresentation gridRepresentation;
+
+    /**
      * Information about the content of a grid data cell, or {@code null} if none.
      * May also be an instance of {@link DefaultImageDescription} if {@link #electromagnetic} is {@code true}.
      */
@@ -199,7 +209,7 @@ public class MetadataBuilder {
      *
      * @see #parseDouble(String)
      */
-    private final Map<Double,Double> sharedNumbers = new HashMap<>();
+    private final Map<Number,Number> sharedNumbers = new HashMap<>();
 
     /**
      * Creates a new metadata reader.
@@ -280,6 +290,24 @@ public class MetadataBuilder {
     }
 
     /**
+     * Commits all pending information under the metadata "spatial representation" node (dimensions, <i>etc</i>).
+     * If there is no pending spatial representation information, then invoking this method has no effect.
+     * If new spatial representation info are added after this method call, they will be stored in a new element.
+     *
+     * <p>This method does not need to be invoked unless a new "spatial representation info" node,
+     * separated from the previous one, is desired.</p>
+     */
+    public final void newGridRepresentation() {
+        if (gridRepresentation != null) {
+            if (!gridRepresentation.isEmpty()) {
+                gridRepresentation.setNumberOfDimensions(shared(gridRepresentation.getAxisDimensionProperties().size()));
+            }
+            metadata.getSpatialRepresentationInfo().add(gridRepresentation);
+            gridRepresentation = null;
+        }
+    }
+
+    /**
      * Commits all pending information under the metadata "content info" node (bands, <i>etc</i>).
      * If there is no pending coverage description, then invoking this method has no effect
      * except setting the {@code electromagnetic} flag.
@@ -444,6 +472,18 @@ public class MetadataBuilder {
     }
 
     /**
+     * Creates a grid representation object if it does not already exists, then returns it.
+     *
+     * @return the grid representation object (never {@code null}).
+     */
+    private DefaultGridSpatialRepresentation gridRepresentation() {
+        if (gridRepresentation == null) {
+            gridRepresentation = new DefaultGridSpatialRepresentation();
+        }
+        return gridRepresentation;
+    }
+
+    /**
      * Creates the sample dimension object if it does not already exists, then returns it.
      *
      * @return the sample dimension (never {@code null}).
@@ -1102,8 +1142,42 @@ parse:      for (int i = 0; i < length;)
     }
 
     /**
+     * Returns the axis at the given dimension index. All previous dimensions are created if needed.
+     *
+     * @param  index  index of the desired dimension.
+     * @return dimension at the given index.
+     */
+    private DefaultDimension axis(final short index) {
+        final List<Dimension> axes = gridRepresentation().getAxisDimensionProperties();
+        for (int i=axes.size(); i <= index; i++) {
+            axes.add(new DefaultDimension());
+        }
+        return (DefaultDimension) axes.get(index);
+    }
+
+    /**
+     * Sets the number of cells along the given dimension.
+     *
+     * @param  dimension  the axis dimension, as a {@code short} for avoiding excessive values.
+     * @param  name       the name to set for the given dimension.
+     */
+    public final void setAxisName(final short dimension, final DimensionNameType name) {
+        axis(dimension).setDimensionName(name);
+    }
+
+    /**
+     * Sets the number of cells along the given dimension.
+     *
+     * @param  dimension  the axis dimension, as a {@code short} for avoiding excessive values.
+     * @param  length     number of cell values along the given dimension.
+     */
+    public final void setAxisLength(final short dimension, final int length) {
+        axis(dimension).setDimensionSize(shared(length));
+    }
+
+    /**
      * Adds a minimal value for the current sample dimension. If a minimal value was already defined, then
-     * the new value will set only if it is smaller than the existing one. {@code NaN} values are ignored.
+     * the new value will be set only if it is smaller than the existing one. {@code NaN} values are ignored.
      *
      * @param value  the minimal value to add to the existing range of sample values, or {@code NaN}.
      */
@@ -1119,7 +1193,7 @@ parse:      for (int i = 0; i < length;)
 
     /**
      * Adds a maximal value for the current sample dimension. If a maximal value was already defined, then
-     * the new value will set only if it is greater than the existing one. {@code NaN} values are ignored.
+     * the new value will be set only if it is greater than the existing one. {@code NaN} values are ignored.
      *
      * @param value  the maximal value to add to the existing range of sample values, or {@code NaN}.
      */
@@ -1156,6 +1230,7 @@ parse:      for (int i = 0; i < length;)
      */
     public final DefaultMetadata build(final boolean freeze) {
         newIdentification();
+        newGridRepresentation();
         newCoverage(false);
         newDistribution();
         newAcquisition();
@@ -1184,7 +1259,15 @@ parse:      for (int i = 0; i < length;)
      * Returns a shared instance of the given value.
      */
     private Double shared(final Double value) {
-        final Double existing = sharedNumbers.putIfAbsent(value, value);
-        return (existing != null) ? existing : value;
+        final Number existing = sharedNumbers.putIfAbsent(value, value);
+        return (existing != null) ? (Double) existing : value;
+    }
+
+    /**
+     * Returns a shared instance of the given value.
+     */
+    private Integer shared(final Integer value) {
+        final Number existing = sharedNumbers.putIfAbsent(value, value);
+        return (existing != null) ? (Integer) existing : value;
     }
 }



Mime
View raw message