sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jso...@apache.org
Subject [sis] branch geoapi-4.0 updated: Coverage : add GridCoverage2D specific 2D methods
Date Tue, 19 Nov 2019 08:13:28 GMT
This is an automated email from the ASF dual-hosted git repository.

jsorel pushed a commit to branch geoapi-4.0
in repository https://gitbox.apache.org/repos/asf/sis.git


The following commit(s) were added to refs/heads/geoapi-4.0 by this push:
     new b5508f6  Coverage : add GridCoverage2D specific 2D methods
b5508f6 is described below

commit b5508f64145eaf97773de96594eb7b2e395eafac
Author: jsorel <johann.sorel@geomatys.com>
AuthorDate: Mon Nov 18 15:14:10 2019 +0100

    Coverage : add GridCoverage2D specific 2D methods
---
 .../sis/internal/coverage/GridCoverage2D.java      | 33 ++++++++++++++++++++++
 1 file changed, 33 insertions(+)

diff --git a/core/sis-feature/src/main/java/org/apache/sis/internal/coverage/GridCoverage2D.java
b/core/sis-feature/src/main/java/org/apache/sis/internal/coverage/GridCoverage2D.java
index 247baaf..66c7c59 100644
--- a/core/sis-feature/src/main/java/org/apache/sis/internal/coverage/GridCoverage2D.java
+++ b/core/sis-feature/src/main/java/org/apache/sis/internal/coverage/GridCoverage2D.java
@@ -24,17 +24,22 @@ import org.apache.sis.coverage.grid.GridCoverage;
 import org.apache.sis.coverage.grid.GridExtent;
 import org.apache.sis.coverage.grid.GridGeometry;
 import org.apache.sis.internal.image.TranslatedRenderedImage;
+import org.apache.sis.internal.referencing.AxisDirections;
 import org.apache.sis.referencing.CRS;
+import org.apache.sis.referencing.operation.transform.TransformSeparator;
 import org.apache.sis.util.ArgumentChecks;
 import org.opengis.coverage.CannotEvaluateException;
 import org.opengis.geometry.DirectPosition;
 import org.opengis.referencing.crs.CoordinateReferenceSystem;
+import org.opengis.referencing.datum.PixelInCell;
+import org.opengis.referencing.operation.MathTransform;
 import org.opengis.referencing.operation.TransformException;
 import org.opengis.util.FactoryException;
 
 /**
  * A {@link GridCoverage} with data stored in a {@link RenderedImage}.
  *
+ * @author Martin Desruisseaux (Geomatys)
  * @author Johann Sorel (Geomatys)
  * @version 2.0
  * @since   2.0
@@ -81,6 +86,34 @@ public final class GridCoverage2D extends GridCoverage {
     }
 
     /**
+     * Returns the two-dimensional part of this grid coverage CRS. If the
+     * {@linkplain #getCoordinateReferenceSystem complete CRS} is two-dimensional, then this
+     * method returns the same CRS. Otherwise it returns a CRS for the two first axis having
+     * a {@linkplain GridExtent#getSize span} greater than 1 in the grid envelope. Note that
+     * those axis are guaranteed to appears in the same order than in the complete CRS.
+     *
+     * @return The two-dimensional part of the grid coverage CRS.
+     *
+     * @see #getCoordinateReferenceSystem
+     */
+    public CoordinateReferenceSystem getCoordinateReferenceSystem2D() {
+        return crs2d;
+    }
+
+    /**
+     * Returns the grid to CRS 2D transform in pixel center.
+     *
+     * @return MathTransform grid to CRS 2D transform
+     * @throws FactoryException if separating 2d transform fails.
+     */
+    public MathTransform getGridToCrs2D() throws FactoryException {
+        TransformSeparator sep = new TransformSeparator(getGridGeometry().getGridToCRS(PixelInCell.CELL_CENTER));
+        int idx = AxisDirections.indexOfColinear(getCoordinateReferenceSystem().getCoordinateSystem(),
crs2d.getCoordinateSystem());
+        sep.addSourceDimensionRange(idx, idx+2);
+        return sep.separate();
+    }
+
+    /**
      * Returns a grid coverage that contains real values or sample values, depending if {@code
converted} is {@code true}
      * or {@code false} respectively.
      *


Mime
View raw message