sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1833032 [1/3] - in /sis/branches/JDK8: core/sis-raster/src/main/java/org/apache/sis/coverage/grid/ core/sis-raster/src/test/java/org/apache/sis/coverage/grid/ core/sis-utility/src/main/java/org/apache/sis/util/logging/ storage/sis-geotiff/...
Date Wed, 06 Jun 2018 14:54:43 GMT
Author: desruisseaux
Date: Wed Jun  6 14:54:43 2018
New Revision: 1833032

URL: http://svn.apache.org/viewvc?rev=1833032&view=rev
Log:
First draft of a GeoTIFF reader capable to compute the GridGeometry.

Added:
    sis/branches/JDK8/storage/sis-geotiff/src/main/java/org/apache/sis/storage/geotiff/GridGeometryBuilder.java
      - copied, changed from r1832917, sis/branches/JDK8/storage/sis-geotiff/src/main/java/org/apache/sis/storage/geotiff/ImageFileDirectory.java
Modified:
    sis/branches/JDK8/core/sis-raster/src/main/java/org/apache/sis/coverage/grid/GridGeometry.java
    sis/branches/JDK8/core/sis-raster/src/main/java/org/apache/sis/coverage/grid/PixelTranslation.java
    sis/branches/JDK8/core/sis-raster/src/test/java/org/apache/sis/coverage/grid/GridGeometryTest.java
    sis/branches/JDK8/core/sis-raster/src/test/java/org/apache/sis/coverage/grid/PixelTranslationTest.java
    sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/logging/WarningListeners.java
    sis/branches/JDK8/storage/sis-geotiff/src/main/java/org/apache/sis/internal/geotiff/Resources.java
    sis/branches/JDK8/storage/sis-geotiff/src/main/java/org/apache/sis/internal/geotiff/Resources.properties
    sis/branches/JDK8/storage/sis-geotiff/src/main/java/org/apache/sis/internal/geotiff/Resources_fr.properties
    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/ImageFileDirectory.java
    sis/branches/JDK8/storage/sis-geotiff/src/main/java/org/apache/sis/storage/geotiff/Localization.java

Modified: sis/branches/JDK8/core/sis-raster/src/main/java/org/apache/sis/coverage/grid/GridGeometry.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-raster/src/main/java/org/apache/sis/coverage/grid/GridGeometry.java?rev=1833032&r1=1833031&r2=1833032&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-raster/src/main/java/org/apache/sis/coverage/grid/GridGeometry.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-raster/src/main/java/org/apache/sis/coverage/grid/GridGeometry.java
[UTF-8] Wed Jun  6 14:54:43 2018
@@ -16,6 +16,7 @@
  */
 package org.apache.sis.coverage.grid;
 
+import java.util.Arrays;
 import java.util.Objects;
 import java.io.Serializable;
 import java.awt.image.RenderedImage;            // For javadoc only.
@@ -286,6 +287,30 @@ public class GridGeometry implements Ser
         }
     }
 
+    /**
+     * Creates a grid geometry with only an extent and a coordinate reference system.
+     * This constructor can be used when the <cite>grid to CRS</cite> transform
is unknown.
+     *
+     * @param  extent     the valid extent of grid coordinates, or {@code null} if unknown.
+     * @param  crs        the coordinate reference system of the "real world" coordinates,
or {@code null} if unknown.
+     * @throws NullPointerException if {@code extent} and {@code crs} arguments are both
null.
+     */
+    public GridGeometry(final GridExtent extent, final CoordinateReferenceSystem crs) {
+        this.extent = extent;
+        gridToCRS   = null;
+        cornerToCRS = null;
+        resolution  = null;
+        nonLinears  = 0;
+        if (crs == null) {
+            ArgumentChecks.ensureNonNull("extent", extent);
+            envelope = null;
+        } else {
+            final double[] coords = new double[crs.getCoordinateSystem().getDimension()];
+            Arrays.fill(coords, Double.NaN);
+            envelope = new ImmutableEnvelope(coords, coords, crs);
+        }
+    }
+
     /**
      * Returns the number of dimensions of the <em>grid</em>. This is typically
the same
      * than the number of {@linkplain #getEnvelope() envelope} dimensions or the number of

Modified: sis/branches/JDK8/core/sis-raster/src/main/java/org/apache/sis/coverage/grid/PixelTranslation.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-raster/src/main/java/org/apache/sis/coverage/grid/PixelTranslation.java?rev=1833032&r1=1833031&r2=1833032&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-raster/src/main/java/org/apache/sis/coverage/grid/PixelTranslation.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-raster/src/main/java/org/apache/sis/coverage/grid/PixelTranslation.java
[UTF-8] Wed Jun  6 14:54:43 2018
@@ -55,11 +55,11 @@ import org.apache.sis.referencing.operat
  * {@preformat java
  *   final AffineTransform  gridToCRS = ...;
  *   final PixelOrientation current   = PixelOrientation.CENTER;
- *   final PixelOrientation expected  = PixelOrientation.UPPER_LEFT;
+ *   final PixelOrientation desired   = PixelOrientation.UPPER_LEFT;
  *
- *   // Switch the transform from 'current' to 'expected' convention.
+ *   // Switch the transform from 'current' to 'desired' convention.
  *   final PixelTranslation source = getPixelTranslation(current);
- *   final PixelTranslation target = getPixelTranslation(expected);
+ *   final PixelTranslation target = getPixelTranslation(desired);
  *   gridToCRS.translate(target.dx - source.dx,
  *                       target.dy - source.dy);
  * }
@@ -224,30 +224,29 @@ public final class PixelTranslation exte
      * If the two given conventions are the same, then this method returns the given transform
unchanged.
      *
      * <div class="note"><b>Example:</b>
-     * if a given {@code gridToCRS} was mapping the pixel corner to "real world" coordinates,
then a call to
-     * <code>translate(gridToCRS, {@link PixelInCell#CELL_CORNER}, {@link PixelInCell#CELL_CENTER})</code>
-     * will return a new transform performing the following steps:
-     * <ol>
-     *   <li>Translate the grid coordinates by +0.5, so that the (0,0) coordinate in
"pixel center" convention
-     *       map to (½,½) in "pixel corner" convention.</li>
-     *   <li>Apply the transform described by the "pixel corner" convention.</li>
-     * </ol></div>
+     * if a given {@code gridToCRS} transform was mapping the <em>cell corner</em>
to "real world" coordinates, then a call to
+     * <code>translate(gridToCRS, {@link PixelInCell#CELL_CORNER CELL_CORNER}, {@link
PixelInCell#CELL_CENTER CELL_CENTER})</code>
+     * will return a new transform performing the following steps: first convert grid coordinates
from <var>cell center</var>
+     * convention ({@code desired}) to <var>cell corner</var> convention ({@code
current}), then concatenate the given
+     * {@code gridToCRS} transform which was designed for the <em>cell corner</em>
convention.
+     * The above-cited <var>cell center</var> → <var>cell corner</var>
conversion is done by translating the grid coordinates
+     * by +½, because the grid coordinates (0,0) relative to cell center is (½,½) relative
to cell corner.</div>
      *
      * If the given {@code gridToCRS} is null, then this method ignores all other arguments
and returns {@code null}.
-     * Otherwise {@code current} and {@code expected} arguments must be non-null.
+     * Otherwise {@code current} and {@code desired} arguments must be non-null.
      *
      * @param  gridToCRS  a math transform from <cite>pixel</cite> coordinates
to any CRS, or {@code null}.
      * @param  current    the pixel orientation of the given {@code gridToCRS} transform.
-     * @param  expected   the pixel orientation of the desired transform.
-     * @return the translation from {@code current} to {@code expected}, or {@code null}
if {@code gridToCRS} was null.
-     * @throws IllegalArgumentException if {@code current} or {@code expected} is not a known
code list value.
+     * @param  desired    the pixel orientation of the desired transform.
+     * @return the translation from {@code current} to {@code desired}, or {@code null} if
{@code gridToCRS} was null.
+     * @throws IllegalArgumentException if {@code current} or {@code desired} is not a known
code list value.
      */
-    public static MathTransform translate(final MathTransform gridToCRS, final PixelInCell
current, final PixelInCell expected) {
-        if (gridToCRS == null || expected.equals(current)) {
+    public static MathTransform translate(final MathTransform gridToCRS, final PixelInCell
current, final PixelInCell desired) {
+        if (gridToCRS == null || desired.equals(current)) {
             return gridToCRS;
         }
         final int dimension = gridToCRS.getSourceDimensions();
-        final double offset = getPixelTranslation(expected) - getPixelTranslation(current);
+        final double offset = getPixelTranslation(desired) - getPixelTranslation(current);
         final int ci;               // Cache index.
         if (offset == -0.5) {
             ci = 2*dimension - 2;
@@ -275,32 +274,27 @@ public final class PixelTranslation exte
      * The given transform can have any number of input and output dimensions, but only two
of them will be converted.
      *
      * <div class="note"><b>Example:</b>
-     * if a given {@code gridToCRS} was mapping the upper-left corner to "real world" coordinates,
then a call to
-     * <code>translate(gridToCRS, {@link PixelOrientation#UPPER_LEFT}, {@link PixelOrientation#CENTER},
0, 1)</code>
-     * will return a new transform performing the following steps:
-     * <ol>
-     *   <li>Translate the grid coordinates by +0.5, so that the (0,0) coordinate in
"pixel center" convention
-     *       map to (½,½) in "upper-left corner" convention. This translation is applied
only in the specified
-     *       grid (source) dimensions; all other dimensions (if any) are left unchanged.</li>
-     *   <li>Apply the transform described by the "upper-left corner" convention.</li>
-     * </ol></div>
+     * if a given {@code gridToCRS} transform was mapping the upper-left corner to "real
world" coordinates, then a call to
+     * <code>translate(gridToCRS, {@link PixelOrientation#UPPER_LEFT UPPER_LEFT}, {@link
PixelOrientation#CENTER CENTER}, 0, 1)</code>
+     * will return a new transform translating grid coordinates by +0.5 before to apply the
given {@code gridToCRS} transform.
+     * See example in above {@link #translate(MathTransform, PixelInCell, PixelInCell) translate}
method for more details.</div>
      *
      * If the given {@code gridToCRS} is null, then this method ignores all other arguments
and returns {@code null}.
-     * Otherwise {@code current} and {@code expected} arguments must be non-null.
+     * Otherwise {@code current} and {@code desired} arguments must be non-null.
      *
      * @param  gridToCRS   a math transform from <cite>pixel</cite> coordinates
to any CRS, or {@code null}.
      * @param  current     the pixel orientation of the given {@code gridToCRS} transform.
-     * @param  expected    the pixel orientation of the desired transform.
+     * @param  desired     the pixel orientation of the desired transform.
      * @param  xDimension  the dimension of <var>x</var> coordinates (pixel columns).
Often 0.
      * @param  yDimension  the dimension of <var>y</var> coordinates (pixel rows).
Often 1.
-     * @return the translation from {@code current} to {@code expected}, or {@code null}
if {@code gridToCRS} was null.
-     * @throws IllegalArgumentException if {@code current} or {@code expected} is not a known
code list value.
+     * @return the translation from {@code current} to {@code desired}, or {@code null} if
{@code gridToCRS} was null.
+     * @throws IllegalArgumentException if {@code current} or {@code desired} is not a known
code list value.
      */
     public static MathTransform translate(final MathTransform gridToCRS,
-            final PixelOrientation current, final PixelOrientation expected,
+            final PixelOrientation current, final PixelOrientation desired,
             final int xDimension, final int yDimension)
     {
-        if (gridToCRS == null || expected.equals(current)) {
+        if (gridToCRS == null || desired.equals(current)) {
             return gridToCRS;
         }
         final int dimension = gridToCRS.getSourceDimensions();
@@ -314,7 +308,7 @@ public final class PixelTranslation exte
             throw illegalDimension("xDimension", "yDimension");
         }
         final PixelTranslation source = getPixelTranslation(current);
-        final PixelTranslation target = getPixelTranslation(expected);
+        final PixelTranslation target = getPixelTranslation(desired);
         final double dx = target.dx - source.dx;
         final double dy = target.dy - source.dy;
         MathTransform mt;

Modified: sis/branches/JDK8/core/sis-raster/src/test/java/org/apache/sis/coverage/grid/GridGeometryTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-raster/src/test/java/org/apache/sis/coverage/grid/GridGeometryTest.java?rev=1833032&r1=1833031&r2=1833032&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-raster/src/test/java/org/apache/sis/coverage/grid/GridGeometryTest.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-raster/src/test/java/org/apache/sis/coverage/grid/GridGeometryTest.java
[UTF-8] Wed Jun  6 14:54:43 2018
@@ -19,6 +19,7 @@ package org.apache.sis.coverage.grid;
 import org.opengis.referencing.datum.PixelInCell;
 import org.opengis.referencing.operation.MathTransform;
 import org.opengis.referencing.operation.TransformException;
+import org.apache.sis.referencing.operation.matrix.Matrix3;
 import org.apache.sis.referencing.operation.matrix.Matrix4;
 import org.apache.sis.referencing.operation.matrix.Matrices;
 import org.apache.sis.referencing.operation.transform.MathTransforms;
@@ -52,7 +53,7 @@ public final strictfp class GridGeometry
      * @throws TransformException if an error occurred while using the "grid to CRS" transform.
      */
     @Test
-    public void testSimple() throws TransformException {
+    public void testFromPixelCorner() throws TransformException {
         final long[]         low     = new long[] {100, 300, 3, 6};
         final long[]         high    = new long[] {200, 400, 4, 7};
         final GridExtent    extent   = new GridExtent(low, high, true);
@@ -98,7 +99,7 @@ public final strictfp class GridGeometry
      * @throws TransformException if an error occurred while using the "grid to CRS" transform.
      */
     @Test
-    public void testShifted() throws TransformException {
+    public void testFromPixelCenter() throws TransformException {
         final long[]        low      = new long[] { 0,   0, 2};
         final long[]        high     = new long[] {99, 199, 4};
         final GridExtent    extent   = new GridExtent(low, high, true);
@@ -137,6 +138,26 @@ public final strictfp class GridGeometry
     }
 
     /**
+     * Tests construction from a <cite>grid to CRS</cite> having a 0.5 pixel
translation.
+     * This translation happens in transform mapping <cite>pixel center</cite>
when the
+     * corresponding <cite>pixel corner</cite> transformation is identity.
+     *
+     * @throws TransformException if an error occurred while using the "grid to CRS" transform.
+     */
+    @Test
+    public void testShifted() throws TransformException {
+        final long[]        low      = new long[] {100, 300};
+        final long[]        high     = new long[] {200, 400};
+        final GridExtent    extent   = new GridExtent(low, high, true);
+        final MathTransform identity = MathTransforms.linear(new Matrix3(
+                1, 0, 0.5,
+                0, 1, 0.5,
+                0, 0, 1));
+        final GridGeometry grid = new GridGeometry(extent, PixelInCell.CELL_CENTER, identity,
null);
+        assertTrue("gridToCRS.isIdentity", grid.getGridToCRS(PixelInCell.CELL_CORNER).isIdentity());
+    }
+
+    /**
      * Tests construction with a non-linear component in the transform.
      *
      * @throws TransformException if an error occurred while using the "grid to CRS" transform.

Modified: sis/branches/JDK8/core/sis-raster/src/test/java/org/apache/sis/coverage/grid/PixelTranslationTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-raster/src/test/java/org/apache/sis/coverage/grid/PixelTranslationTest.java?rev=1833032&r1=1833031&r2=1833032&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-raster/src/test/java/org/apache/sis/coverage/grid/PixelTranslationTest.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-raster/src/test/java/org/apache/sis/coverage/grid/PixelTranslationTest.java
[UTF-8] Wed Jun  6 14:54:43 2018
@@ -19,6 +19,7 @@ package org.apache.sis.coverage.grid;
 import org.opengis.metadata.spatial.PixelOrientation;
 import org.opengis.referencing.datum.PixelInCell;
 import org.opengis.referencing.operation.MathTransform;
+import org.opengis.referencing.operation.TransformException;
 import org.apache.sis.referencing.operation.transform.MathTransforms;
 import org.apache.sis.referencing.operation.matrix.Matrix3;
 import org.apache.sis.referencing.operation.matrix.Matrix4;
@@ -52,20 +53,34 @@ public final strictfp class PixelTransla
     }
 
     /**
-     * Tests {@link PixelTranslation#translate(MathTransform, PixelInCell, PixelInCell)}.
+     * Tests {@link PixelTranslation#translate(MathTransform, PixelInCell, PixelInCell)}
with an identity transform.
+     * If grid coordinates (0,0) in "pixel center" convention map to (0,0) in "real world"
coordinates,
+     * then grid coordinates (0,0) in "pixel corner" convention shall map to (-½, -½) in
real world.
+     * That way, grid coordinates (½,½) in "pixel corner" convention still map to (0,0)
in real world.
+     *
+     * @throws TransformException if an error occurred while transforming a test point.
      */
     @Test
-    public void testTranslatePixelInCell() {
+    public void testTranslatePixelInCell() throws TransformException {
         final MathTransform mt = centerToCorner(3);
         assertMatrixEquals("center → corner", new Matrix4(
                 1, 0, 0, -0.5,
                 0, 1, 0, -0.5,
                 0, 0, 1, -0.5,
                 0, 0, 0,  1), MathTransforms.getMatrix(mt), STRICT);
+        /*
+         * Just for making clear what we explained in javadoc comment: the real world (0,0,0)
coordinates was in the center
+         * of cell (0,0,0). After we switched to "cell corner" convention, that center is
(½,½,½) in grid coordinates but
+         * should still map (0,0,0) in "real world" coordinates.
+         */
+        final double[] coordinates = new double[] {0.5, 0.5, 0.5};
+        mt.transform(coordinates, 0, coordinates, 0, 1);
+        assertArrayEquals(new double[3], coordinates, STRICT);
     }
 
     /**
      * Tests {@link PixelTranslation#translate(MathTransform, PixelOrientation, PixelOrientation,
int, int)}.
+     * See {@link #testTranslatePixelInCell()} for discussion on expected values.
      */
     @Test
     public void testTranslatePixelOrientation() {
@@ -76,7 +91,7 @@ public final strictfp class PixelTransla
                 0, 0,  1), MathTransforms.getMatrix(mt), STRICT);
 
         mt = PixelTranslation.translate(MathTransforms.identity(3), PixelOrientation.LOWER_LEFT,
PixelOrientation.CENTER, 1, 2);
-        assertMatrixEquals("center → corner", new Matrix4(
+        assertMatrixEquals("corner → center", new Matrix4(
                 1, 0, 0,  0.0,
                 0, 1, 0, +0.5,
                 0, 0, 1, -0.5,

Modified: sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/logging/WarningListeners.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/logging/WarningListeners.java?rev=1833032&r1=1833031&r2=1833032&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/logging/WarningListeners.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/logging/WarningListeners.java
[UTF-8] Wed Jun  6 14:54:43 2018
@@ -71,7 +71,7 @@ import org.apache.sis.internal.util.Unmo
 public class WarningListeners<S> implements Localized {
     /**
      * The declared source of warnings. This is not necessarily the real source,
-     * but this is the source that the implementor wants to declare as public API.
+     * but this is the source that the implementer wants to declare as public API.
      */
     private final S source;
 
@@ -95,7 +95,7 @@ public class WarningListeners<S> impleme
      * unless at least one listener is {@linkplain #addWarningListener registered}.
      *
      * @param source  the declared source of warnings. This is not necessarily the real source,
-     *                but this is the source that the implementor wants to declare as public
API.
+     *                but this is the source that the implementer wants to declare as public
API.
      */
     public WarningListeners(final S source) {
         ArgumentChecks.ensureNonNull("source", source);
@@ -108,7 +108,7 @@ public class WarningListeners<S> impleme
      * be duplicated for concurrency reasons.
      *
      * @param source  the declared source of warnings. This is not necessarily the real source,
-     *                but this is the source that the implementor wants to declare as public
API.
+     *                but this is the source that the implementer wants to declare as public
API.
      * @param other   the existing instance from which to copy the listeners, or {@code null}
if none.
      *
      * @since 0.8
@@ -231,7 +231,7 @@ public class WarningListeners<S> impleme
      * If the stack trace is desired, then users can either:
      * <ul>
      *   <li>invoke {@code warning(LogRecord)} directly, or</li>
-     *   <li>override {@code warning(LogRecord)} and invoke {@link LogRecord#setThrown(Throwable)}
explicitely, or</li>
+     *   <li>override {@code warning(LogRecord)} and invoke {@link LogRecord#setThrown(Throwable)}
explicitly, or</li>
      *   <li>register a listener which will log the record itself.</li>
      * </ul>
      *

Modified: sis/branches/JDK8/storage/sis-geotiff/src/main/java/org/apache/sis/internal/geotiff/Resources.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-geotiff/src/main/java/org/apache/sis/internal/geotiff/Resources.java?rev=1833032&r1=1833031&r2=1833032&view=diff
==============================================================================
--- sis/branches/JDK8/storage/sis-geotiff/src/main/java/org/apache/sis/internal/geotiff/Resources.java
[UTF-8] (original)
+++ sis/branches/JDK8/storage/sis-geotiff/src/main/java/org/apache/sis/internal/geotiff/Resources.java
[UTF-8] Wed Jun  6 14:54:43 2018
@@ -61,6 +61,11 @@ public final class Resources extends Ind
         }
 
         /**
+         * Can not compute the grid geometry of “{0}” TIFF file.
+         */
+        public static final short CanNotComputeGridGeometry_1 = 26;
+
+        /**
          * TIFF file “{0}” has circular references in its chain of images.
          */
         public static final short CircularImageReference_1 = 1;

Modified: sis/branches/JDK8/storage/sis-geotiff/src/main/java/org/apache/sis/internal/geotiff/Resources.properties
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-geotiff/src/main/java/org/apache/sis/internal/geotiff/Resources.properties?rev=1833032&r1=1833031&r2=1833032&view=diff
==============================================================================
--- sis/branches/JDK8/storage/sis-geotiff/src/main/java/org/apache/sis/internal/geotiff/Resources.properties
[ISO-8859-1] (original)
+++ sis/branches/JDK8/storage/sis-geotiff/src/main/java/org/apache/sis/internal/geotiff/Resources.properties
[ISO-8859-1] Wed Jun  6 14:54:43 2018
@@ -19,6 +19,7 @@
 # Resources in this file are for "sis-geotiff" usage only and should not be used by any other
module.
 # For resources shared by all modules in the Apache SIS project, see "org.apache.sis.util.resources"
package.
 #
+CanNotComputeGridGeometry_1       = Can not compute the grid geometry of \u201c{0}\u201d
TIFF file.
 CircularImageReference_1          = TIFF file \u201c{0}\u201d has circular references in
its chain of images.
 ConstantValueRequired_3           = Apache SIS implementation requires that all \u201c{0}\u201d
elements have the same value, but the element found in \u201c{1}\u201d are {2}.
 ComputedValueForAttribute_2       = No value specified for the \u201c{0}\u201d TIFF tag.
Computed the {1} value from other tags.

Modified: sis/branches/JDK8/storage/sis-geotiff/src/main/java/org/apache/sis/internal/geotiff/Resources_fr.properties
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-geotiff/src/main/java/org/apache/sis/internal/geotiff/Resources_fr.properties?rev=1833032&r1=1833031&r2=1833032&view=diff
==============================================================================
--- sis/branches/JDK8/storage/sis-geotiff/src/main/java/org/apache/sis/internal/geotiff/Resources_fr.properties
[ISO-8859-1] (original)
+++ sis/branches/JDK8/storage/sis-geotiff/src/main/java/org/apache/sis/internal/geotiff/Resources_fr.properties
[ISO-8859-1] Wed Jun  6 14:54:43 2018
@@ -24,6 +24,7 @@
 #   U+202F NARROW NO-BREAK SPACE  before  ; ! and ?
 #   U+00A0 NO-BREAK SPACE         before  :
 #
+CanNotComputeGridGeometry_1       = Ne peut pas calculer la g\u00e9om\u00e9trie de la grille
du fichier TIFF \u00ab\u202f{0}\u202f\u00bb.
 CircularImageReference_1          = Le fichier TIFF \u00ab\u202f{0}\u202f\u00bb a des r\u00e9f\u00e9rences
circulaires dans sa cha\u00eene d\u2019images.
 ConstantValueRequired_3           = L\u2019impl\u00e9mentation de Apache SIS requiert que
tous les \u00e9l\u00e9ments de \u00ab\u202f{0}\u202f\u00bb aient la m\u00eame valeur, mais
les \u00e9l\u00e9ments trouv\u00e9s dans \u00ab\u202f{1}\u202f\u00bb sont {2}.
 ComputedValueForAttribute_2       = Aucune valeur n\u2019a \u00e9t\u00e9 sp\u00e9cifi\u00e9e
pour le tag TIFF \u00ab\u202f{0}\u202f\u00bb. La valeur {1} a \u00e9t\u00e9 calcul\u00e9e
\u00e0 partir des autres tags.

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=1833032&r1=1833031&r2=1833032&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] Wed Jun  6 14:54:43 2018
@@ -35,7 +35,6 @@ import javax.measure.quantity.Length;
 
 import org.opengis.metadata.Identifier;
 import org.opengis.metadata.spatial.CellGeometry;
-import org.opengis.metadata.spatial.PixelOrientation;
 import org.opengis.parameter.ParameterValueGroup;
 import org.opengis.parameter.ParameterNotFoundException;
 import org.opengis.referencing.IdentifiedObject;
@@ -64,7 +63,6 @@ import org.apache.sis.internal.metadata.
 import org.apache.sis.internal.referencing.CoordinateOperations;
 import org.apache.sis.internal.referencing.NilReferencingObject;
 import org.apache.sis.internal.referencing.ReferencingUtilities;
-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.internal.util.Utilities;
@@ -203,7 +201,7 @@ final class CRSBuilder {
      * so we can easily detect at the end of the parsing process which GeoTIFF keys were
      * unrecognized or ignored.
      */
-    private final Map<Short,Object> geoKeys = new HashMap<>();
+    private final Map<Short,Object> geoKeys;
 
     /**
      * Factory for creating geodetic objects from EPSG codes, or {@code null} if not yet
fetched.
@@ -247,6 +245,19 @@ final class CRSBuilder {
     private Identifier lastName;
 
     /**
+     * Suggested value for a general description of the transformation form grid coordinates
to "real world" coordinates.
+     * This is computed by {@link #build(Vector, Vector, String)} and made available as additional
information to the caller.
+     */
+    public String description;
+
+    /**
+     * {@code POINT} if {@link GeoKeys#RasterType} is {@link GeoCodes#RasterPixelIsPoint},
+     * {@code AREA} if it is {@link GeoCodes#RasterPixelIsArea}, or null if unspecified.
+     * This is computed by {@link #build(Vector, Vector, String)} and made available to the
caller.
+     */
+    public CellGeometry cellGeometry;
+
+    /**
      * {@code true} when an exception has been thrown but this {@code CRSBuilder} already
reported a warning,
      * so there is no need for the caller to report a warning again. {@code CRSBuilder} sometime
reports warnings
      * itself when it can provide a better warning message than what the caller can do.
@@ -260,6 +271,7 @@ final class CRSBuilder {
      */
     CRSBuilder(final Reader reader) {
         this.reader = reader;
+        geoKeys = new HashMap<>();
     }
 
     /**
@@ -483,7 +495,7 @@ final class CRSBuilder {
 
     /**
      * Verifies that a value found in the GeoTIFF file is approximatively equal to the expected
value.
-     * This method is invoked when a CRS component is defined both explicitely and by EPSG
code,
+     * This method is invoked when a CRS component is defined both explicitly and by EPSG
code,
      * in which case we expect the given value to be equal to the value fetched from the
EPSG database.
      * If the values do not match, a warning is reported and the caller should use the EPSG
value.
      *
@@ -554,6 +566,8 @@ final class CRSBuilder {
     /**
      * Decodes all the given GeoTIFF keys, then creates a coordinate reference system.
      * An overview of the key directory structure is given in {@linkplain CRSBuilder class
javadoc}.
+     * The {@link #description} and {@link #cellGeometry} fields are set as a side-effect.
+     * A warning is emitted if any GeoTIFF tags were ignored.
      *
      * @param  keyDirectory       the GeoTIFF keys to be associated to values. Can not be
null.
      * @param  numericParameters  a vector of {@code double} parameters, or {@code null}
if none.
@@ -566,7 +580,7 @@ final class CRSBuilder {
      * @throws FactoryException if an error occurred during objects creation with the factories.
      */
     @SuppressWarnings("null")
-    final CoordinateReferenceSystem build(final Vector keyDirectory, final Vector numericParameters,
final String asciiParameters)
+    public CoordinateReferenceSystem build(final Vector keyDirectory, final Vector numericParameters,
final String asciiParameters)
             throws FactoryException
     {
         final int numberOfKeys;
@@ -703,80 +717,44 @@ final class CRSBuilder {
             geoKeys.put(key, value);
         }
         /*
-         * At this point we finished copying all GeoTIFF keys in 'CRSBuilder.geoKeys' map.
+         * At this point we finished copying all GeoTIFF keys in the 'geoKeys' map. Before
to create the CRS,
+         * store a few metadata. The first one is an ASCII reference to published documentation
on the overall
+         * configuration of the GeoTIFF file. In practice it seems to be often the projected
CRS name, despite
+         * GeoKeys.PCSCitation being already for that purpose.
+         */
+        description = getAsString(GeoKeys.Citation);
+        int code = getAsInteger(GeoKeys.RasterType);
+        switch (code) {
+            case GeoCodes.undefined: break;
+            case GeoCodes.RasterPixelIsArea:  cellGeometry = CellGeometry.AREA;  break;
+            case GeoCodes.RasterPixelIsPoint: cellGeometry = CellGeometry.POINT; break;
+            default: invalidValue(GeoKeys.RasterType, code); break;
+        }
+        /*
          * First create the main coordinate reference system, as determined by 'ModelType'.
          * Then if a vertical CRS exists and the main CRS is not geocentric (in which case
          * adding a vertical CRS would make no sense), create a three-dimensional compound
CRS.
          */
-        CoordinateReferenceSystem crs;
+        CoordinateReferenceSystem crs = null;
         final int crsType = getAsInteger(GeoKeys.ModelType);
         switch (crsType) {
-            case GeoCodes.undefined:           return null;
-            case GeoCodes.ModelTypeProjected:  crs = createProjectedCRS(); break;
-            case GeoCodes.ModelTypeGeocentric: return createGeocentricCRS();        // Ignore
vertical CRS.
-            case GeoCodes.ModelTypeGeographic: {
-                crs = createGeographicCRS(true,
-                        createUnit(GeoKeys.AngularUnits, GeoKeys.AngularUnitSize, Angle.class,
Units.DEGREE));
-                break;
-            }
-            default: {
-                warning(Resources.Keys.UnsupportedCoordinateSystemKind_1, crsType);
-                return null;
+            case GeoCodes.undefined:           break;
+            case GeoCodes.ModelTypeProjected:  crs = createProjectedCRS();  break;
+            case GeoCodes.ModelTypeGeocentric: crs = createGeocentricCRS(); break;
+            case GeoCodes.ModelTypeGeographic: crs = createGeographicCRS(); break;
+            default: warning(Resources.Keys.UnsupportedCoordinateSystemKind_1, crsType);
break;
+        }
+        if (crsType != GeoCodes.ModelTypeGeocentric) {
+            final VerticalCRS vertical = createVerticalCRS();
+            if (crs == null) {
+                crs = vertical;
+            } else if (vertical != null) {
+                crs = objectFactory().createCompoundCRS(Collections.singletonMap(IdentifiedObject.NAME_KEY,
crs.getName()), crs, vertical);
             }
         }
-        final VerticalCRS vertical = createVerticalCRS();
-        if (vertical != null) {
-            crs = objectFactory().createCompoundCRS(Collections.singletonMap(IdentifiedObject.NAME_KEY,
crs.getName()), crs, vertical);
-        }
-        return crs;
-    }
-
-    /**
-     * 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.
-     *
-     * <p><b>Pre-requite:</b></p>
-     * <ul>
-     *   <li>{@link #build(Vector, Vector, String)} must have been invoked before this
method.</li>
-     *   <li>{@link ImageFileDirectory} must have filled its part of metadata before
to invoke this method.</li>
-     *   <li>{@link MetadataBuilder#newGridRepresentation(MetadataBuilder.GridType)}
should have been invoked
-     *       with the appropriate {@code GEORECTIFIED} or {@code GEOREFERENCEABLE} type.</li>
-     * </ul>
-     *
-     * After execution, this method emits a warning for unprocessed GeoTIFF tags.
-     *
-     * @param  metadata  the helper class where to write metadata values.
-     * @throws NumberFormatException if a numeric value was stored as a string and can not
be parsed.
-     */
-    final void complete(final MetadataBuilder metadata) {
-        /*
-         * ASCII reference to published documentation on the overall configuration of the
GeoTIFF file.
-         * Often the projected CRS name, despite GeoKeys.PCSCitation being already for that
purpose.
-         * Checked first because this code is unlikely to throw an exception, while other
parsings may
-         * interrupt this method with an exception.
-         */
-        final String title = getAsString(GeoKeys.Citation);
-        if (title != null) {
-            metadata.setGridToCRS(title);
-        }
-        /*
-         * 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 GeoCodes.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);
         /*
-         * Build a list of remaining GeoKeys.
+         * At this point we finished parsing all GeoTIFF tags, both for metadata purpose
or for CRS construction.
+         * Emit a warning for unprocessed GeoTIFF tags. A single warning is emitted for all
ignored tags.
          */
         if (!geoKeys.isEmpty()) {
             final StringJoiner joiner = new StringJoiner(", ");
@@ -785,6 +763,7 @@ final class CRSBuilder {
             }
             warning(Resources.Keys.IgnoredGeoKeys_1, joiner.toString());
         }
+        return crs;
     }
 
     /**
@@ -1216,6 +1195,13 @@ final class CRSBuilder {
     }
 
     /**
+     * Creates the main CRS in the case where that CRS is geographic.
+     */
+    private GeographicCRS createGeographicCRS() throws FactoryException {
+        return createGeographicCRS(true, createUnit(GeoKeys.AngularUnits, GeoKeys.AngularUnitSize,
Angle.class, Units.DEGREE));
+    }
+
+    /**
      * Creates a geographic CRS from an EPSG code or from user-defined parameters.
      * The GeoTIFF values used by this method are:
      *



Mime
View raw message