[jira] [Resolved] (SIS-524) Image masking based on a geometry

2021-10-22 Thread Martin Desruisseaux (Jira)


 [ 
https://issues.apache.org/jira/browse/SIS-524?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Martin Desruisseaux resolved SIS-524.
-
Resolution: Fixed

> Image masking based on a geometry
> -
>
> Key: SIS-524
> URL: https://issues.apache.org/jira/browse/SIS-524
> Project: Spatial Information Systems
>  Issue Type: New Feature
>  Components: Coverage
>Reporter: Martin Desruisseaux
>Assignee: Martin Desruisseaux
>Priority: Major
> Fix For: 1.2
>
>
> Add an image operator for applying a mask on a `GridCoverage`: all pixel 
> values outside a geometry would be replaced by a fill value. The coverage and 
> the geometry are in arbitrary CRS, not necessarily the same.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[sis] branch geoapi-4.0 updated: Initial version of a "clip" or "mask" operation. Add mask and clip operations on grid coverages.

2021-10-22 Thread desruisseaux
This is an automated email from the ASF dual-hosted git repository.

desruisseaux 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 7a62166  Initial version of a "clip" or "mask" operation. Add mask and 
clip operations on grid coverages.
7a62166 is described below

commit 7a621661bc5d7742a62c7571bcdc483257f10c87
Author: Martin Desruisseaux 
AuthorDate: Fri Oct 22 12:25:35 2021 +0200

Initial version of a "clip" or "mask" operation.
Add mask and clip operations on grid coverages.

https://issues.apache.org/jira/browse/SIS-524
---
 .../org/apache/sis/coverage/RegionOfInterest.java  | 156 +
 .../coverage/grid/CoordinateOperationFinder.java   |   2 +-
 .../apache/sis/coverage/grid/GridCoverage2D.java   |  67 +++-
 .../sis/coverage/grid/GridCoverageProcessor.java   |  73 -
 .../java/org/apache/sis/image/ImageProcessor.java  |  40 +++
 .../java/org/apache/sis/image/MaskedImage.java | 364 +
 .../java/org/apache/sis/image/ResampledImage.java  |  30 +-
 .../org/apache/sis/image/SourceAlignedImage.java   |  21 +-
 .../sis/internal/coverage/j2d/FillValues.java  | 188 +++
 .../sis/internal/coverage/j2d/TilePlaceholder.java |  76 +
 10 files changed, 972 insertions(+), 45 deletions(-)

diff --git 
a/core/sis-feature/src/main/java/org/apache/sis/coverage/RegionOfInterest.java 
b/core/sis-feature/src/main/java/org/apache/sis/coverage/RegionOfInterest.java
new file mode 100644
index 000..fb82f68
--- /dev/null
+++ 
b/core/sis-feature/src/main/java/org/apache/sis/coverage/RegionOfInterest.java
@@ -0,0 +1,156 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sis.coverage;
+
+import java.awt.Shape;
+import java.util.Objects;
+import java.io.Serializable;
+import org.opengis.util.FactoryException;
+import org.opengis.referencing.datum.PixelInCell;
+import org.opengis.referencing.crs.CoordinateReferenceSystem;
+import org.opengis.referencing.operation.CoordinateOperation;
+import org.opengis.referencing.operation.MathTransform;
+import org.opengis.referencing.operation.MathTransform2D;
+import org.opengis.referencing.operation.TransformException;
+import org.apache.sis.referencing.operation.transform.MathTransforms;
+import org.apache.sis.referencing.CRS;
+import org.apache.sis.coverage.grid.GridGeometry;
+import org.apache.sis.util.LenientComparable;
+import org.apache.sis.util.ArgumentChecks;
+import org.apache.sis.util.ComparisonMode;
+import org.apache.sis.util.Utilities;
+
+
+/**
+ * Region of interest (ROI) for an operation to apply on a coverage.
+ *
+ * Multi-threading
+ * Instances of {@code RegionOfInterest} are immutable and thread-safe.
+ *
+ * Limitations
+ * Current implementation supports two-dimensional regions only.
+ * This restriction will be relaxed progressively in future versions.
+ *
+ * Current implementation defines ROI using a geometric shape only.
+ * Future versions may allow other ways such as mask rasters.
+ *
+ * @author  Martin Desruisseaux (Geomatys)
+ * @version 1.2
+ * @since   1.2
+ * @module
+ */
+public class RegionOfInterest implements LenientComparable, Serializable {
+/**
+ * For cross-version compatibility.
+ */
+private static final long serialVersionUID = -8408578541189424074L;
+
+/**
+ * The region of interest as a geometry. Coordinates are in the CRS given 
be {@link #crs}.
+ */
+private final Shape geometry;
+
+/**
+ * The coordinate reference system of the region of interest,
+ * In current version, it shall be a two-dimensional CRS.
+ * May be {@code null} if unknown.
+ */
+private final CoordinateReferenceSystem crs;
+
+/**
+ * Creates a new region of interest from a two-dimensional shape.
+ * If the given CRS is {@code null}, then it will be assumed the same
+ * CRS than the CRS of the coverage on which operations are applied.
+ *
+ * @param  geometry  the ROI as a geometry. Coordinates are in the CRS 
given by {@code crs}.
+ * @param  crs   coordinate reference system of the region of 
interest, or {@code null}.
+