This is an automated email from the ASF dual-hosted git repository. desruisseaux pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/sis.git
commit b94a500b295b52b9fbaf0bb8fdbf43c0ce4e7746 Merge: be181fa 5a19a70 Author: Martin Desruisseaux <martin.desruisse...@geomatys.com> AuthorDate: Thu Nov 4 17:24:40 2021 +0100 Merge branch 'geoapi-3.1' .../main/java/org/apache/sis/gui/DataViewer.java | 32 +- .../main/java/org/apache/sis/gui/RecentFiles.java | 55 ++- .../java/org/apache/sis/gui/SystemMonitor.java | 116 +++++ .../apache/sis/gui/coverage/CoverageCanvas.java | 34 +- .../java/org/apache/sis/gui/coverage/GridView.java | 4 +- .../org/apache/sis/gui/coverage/ImageRequest.java | 17 +- .../org/apache/sis/gui/coverage/RenderingData.java | 13 +- .../org/apache/sis/gui/coverage/package-info.java | 2 +- .../org/apache/sis/gui/dataset/FeatureList.java | 4 +- .../java/org/apache/sis/gui/dataset/LoadEvent.java | 31 +- .../dataset/{LoadEvent.java => ResourceEvent.java} | 41 +- .../apache/sis/gui/dataset/ResourceExplorer.java | 264 ++++++---- .../org/apache/sis/gui/dataset/ResourceTree.java | 529 ++++++++++++++------- .../org/apache/sis/gui/dataset/package-info.java | 6 +- .../java/org/apache/sis/gui/map/MapCanvas.java | 194 +++++++- .../java/org/apache/sis/gui/map/MapCanvasAWT.java | 100 +++- .../java/org/apache/sis/gui/map/package-info.java | 2 +- .../sis/gui/metadata/IdentificationInfo.java | 2 +- .../apache/sis/gui/metadata/MetadataSummary.java | 30 +- .../org/apache/sis/gui/metadata/MetadataTree.java | 7 +- .../org/apache/sis/gui/metadata/package-info.java | 2 +- .../main/java/org/apache/sis/gui/package-info.java | 2 +- .../gui/referencing/RecentReferenceSystems.java | 9 +- .../apache/sis/internal/gui/BackgroundThreads.java | 18 +- .../sis/internal/gui/FixedHeaderColumnSize.java | 89 ++++ .../org/apache/sis/internal/gui/GUIUtilities.java | 19 +- .../sis/internal/gui/OptionalDataDownloader.java | 31 +- .../org/apache/sis/internal/gui/PropertyView.java | 4 +- .../apache/sis/internal/gui/ResourceLoader.java | 46 +- .../org/apache/sis/internal/gui/Resources.java | 22 +- .../apache/sis/internal/gui/Resources.properties | 6 +- .../sis/internal/gui/Resources_fr.properties | 6 +- .../java/org/apache/sis/internal/gui/Styles.java | 2 +- .../apache/sis/internal/gui/io/FileAccessItem.java | 420 ++++++++++++++++ .../apache/sis/internal/gui/io/FileAccessView.java | 136 ++++++ .../apache/sis/internal/gui}/io/package-info.java | 8 +- .../org/apache/sis/internal/gui/package-info.java | 2 +- .../java/org/apache/sis/coverage/CategoryList.java | 4 +- .../org/apache/sis/coverage/RegionOfInterest.java | 156 ++++++ .../org/apache/sis/coverage/SampleDimension.java | 86 +++- .../coverage/grid/CoordinateOperationFinder.java | 2 +- .../apache/sis/coverage/grid/GridCoverage2D.java | 67 ++- .../sis/coverage/grid/GridCoverageProcessor.java | 58 ++- .../apache/sis/coverage/grid/GridDerivation.java | 5 +- .../apache/sis/filter/DefaultFilterFactory.java | 4 +- .../java/org/apache/sis/filter/LogicalFilter.java | 15 +- .../java/org/apache/sis/filter/package-info.java | 2 +- .../java/org/apache/sis/image/ImageProcessor.java | 88 ++-- .../java/org/apache/sis/image/MaskedImage.java | 478 +++++++++++++++++++ .../java/org/apache/sis/image/PrefetchedImage.java | 87 +--- .../java/org/apache/sis/image/ResampledImage.java | 30 +- .../org/apache/sis/image/SourceAlignedImage.java | 21 +- .../java/org/apache/sis/image/Visualization.java | 420 ++++++++++------ .../java/org/apache/sis/image/package-info.java | 9 +- .../internal/coverage/j2d/ColorModelFactory.java | 12 +- .../sis/internal/coverage/j2d/Colorizer.java | 2 +- .../sis/internal/coverage/j2d/FillValues.java | 188 ++++++++ .../sis/internal/coverage/j2d/ImageLayout.java | 46 +- .../sis/internal/coverage/j2d/TilePlaceholder.java | 395 +++++++++++++++ .../sis/internal/coverage/j2d/package-info.java | 2 +- .../org/apache/sis/coverage/CategoryListTest.java | 3 +- .../org/apache/sis/filter/LogicalFilterTest.java | 9 +- .../apache/sis/metadata/sql/CachedStatement.java | 4 +- .../org/apache/sis/metadata/sql/package-info.java | 2 +- core/sis-referencing/pom.xml | 11 + .../factory/ConcurrentAuthorityFactory.java | 8 +- .../referencing/factory/sql/AuthorityCodes.java | 28 +- .../factory/sql/CloseableReference.java | 21 +- .../referencing/factory/sql/EPSGCodeFinder.java | 2 + .../referencing/factory/sql/EPSGDataAccess.java | 30 +- .../sis/referencing/factory/sql/package-info.java | 2 +- .../operation/projection/AzimuthalEquidistant.java | 1 + .../projection/ModifiedAzimuthalEquidistant.java | 6 + .../java/org/apache/sis/math/MathFunctions.java | 9 +- .../java/org/apache/sis/math/package-info.java | 2 +- .../java/org/apache/sis/measure/NumberRange.java | 61 ++- .../java/org/apache/sis/measure/package-info.java | 2 +- .../apache/sis/setup/OptionalInstallations.java | 17 +- .../java/org/apache/sis/setup/package-info.java | 2 +- .../main/java/org/apache/sis/util/ArraysExt.java | 2 +- .../sis/util/collection/DefaultTreeTable.java | 20 +- .../apache/sis/util/collection/package-info.java | 2 +- .../java/org/apache/sis/util/resources/Errors.java | 5 + .../apache/sis/util/resources/Errors.properties | 1 + .../apache/sis/util/resources/Errors_fr.properties | 1 + .../org/apache/sis/util/resources/Vocabulary.java | 5 + .../sis/util/resources/Vocabulary.properties | 1 + .../sis/util/resources/Vocabulary_fr.properties | 1 + .../org/apache/sis/math/MathFunctionsTest.java | 6 +- .../org/apache/sis/measure/NumberRangeTest.java | 4 +- .../org/apache/sis/storage/landsat/BandGroup.java | 2 +- .../apache/sis/internal/geotiff/Compression.java | 34 +- .../sis/internal/geotiff/SchemaModifier.java | 4 +- .../org/apache/sis/storage/geotiff/CRSBuilder.java | 208 +------- .../sis/storage/geotiff/CompressedSubset.java | 8 +- .../org/apache/sis/storage/geotiff/DataCube.java | 2 +- .../org/apache/sis/storage/geotiff/DataSubset.java | 45 +- .../apache/sis/storage/geotiff/GeoKeysLoader.java | 308 ++++++++++++ .../org/apache/sis/storage/geotiff/GeoTIFF.java | 1 + .../apache/sis/storage/geotiff/GeoTiffStore.java | 44 +- .../sis/storage/geotiff/GridGeometryBuilder.java | 22 +- .../sis/storage/geotiff/ImageFileDirectory.java | 19 +- .../apache/sis/storage/geotiff/NativeMetadata.java | 260 ++++++++++ .../org/apache/sis/storage/geotiff/Reader.java | 4 +- .../java/org/apache/sis/storage/geotiff/Type.java | 84 +++- .../apache/sis/storage/geotiff/package-info.java | 2 +- .../sis/internal/netcdf/DiscreteSampling.java | 15 +- .../org/apache/sis/internal/netcdf/FeatureSet.java | 12 +- .../apache/sis/internal/netcdf/RasterResource.java | 13 +- .../apache/sis/internal/netcdf/package-info.java | 2 +- .../sis/internal/sql/feature/SchemaModifier.java | 4 +- .../sis/internal/storage/AbstractFeatureSet.java | 2 +- .../sis/internal/storage/AbstractResource.java | 29 +- .../sis/internal/storage/AggregatedFeatureSet.java | 32 +- .../sis/internal/storage/GridResourceWrapper.java | 34 +- .../sis/internal/storage/TiledGridCoverage.java | 28 +- .../sis/internal/storage/TiledGridResource.java | 26 +- .../sis/internal/storage/io/ChannelDataInput.java | 15 +- .../sis/internal/storage/io/ChannelFactory.java | 39 +- .../sis/internal/storage/io/InternalOptionKey.java | 56 +++ .../sis/internal/storage/io/package-info.java | 2 +- .../java/org/apache/sis/storage/CoverageQuery.java | 12 +- .../org/apache/sis/storage/CoverageSubset.java | 20 +- .../java/org/apache/sis/storage/FeatureQuery.java | 19 +- .../java/org/apache/sis/storage/FeatureSet.java | 12 +- .../apache/sis/storage/GridCoverageResource.java | 52 +- .../org/apache/sis/storage/StorageConnector.java | 9 +- .../java/org/apache/sis/storage/package-info.java | 2 +- .../internal/storage/io/ChannelDataInputTest.java | 7 +- .../internal/storage/io/ChannelDataOutputTest.java | 6 +- .../internal/storage/io/ChannelDataTestCase.java | 15 +- .../storage/io/ChannelImageOutputStreamTest.java | 4 +- .../sis/test/storage/CoverageReadConsistency.java | 4 +- 133 files changed, 5019 insertions(+), 1249 deletions(-) diff --cc core/sis-feature/src/main/java/org/apache/sis/coverage/RegionOfInterest.java index 0000000,fb82f68..45b0cdc mode 000000,100644..100644 --- 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 @@@ -1,0 -1,156 +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. + * + * <h2>Multi-threading</h2> + * Instances of {@code RegionOfInterest} are immutable and thread-safe. + * + * <h2>Limitations</h2> + * Current implementation supports two-dimensional regions only. + * This restriction will be relaxed progressively in future versions. + * + * <p>Current implementation defines ROI using a geometric shape only. + * Future versions may allow other ways such as mask rasters.</p> + * + * @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}. + */ + public RegionOfInterest(final Shape geometry, final CoordinateReferenceSystem crs) { + ArgumentChecks.ensureNonNull("geometry", geometry); + ArgumentChecks.ensureDimensionMatches("crs", 2, crs); + this.geometry = geometry; + this.crs = crs; + } + + /** + * Returns the clip geometry in coordinates of grid cells. + * The target space is specified by a {@code GridGeometry}. + * + * <h4>Limitations</h4> + * In current implementation, the grid geometry most be two-dimensional. + * This restriction will be relaxed progressively in future versions. + * + * @param target two-dimensional grid geometry of the target image. + * @return clip in pixel coordinates of given grid. + * @throws TransformException if ROI coordinates can not be transformed to grid coordinates. + */ + public Shape toShape2D(final GridGeometry target) throws TransformException { + final MathTransform2D crsToGrid; + try { + MathTransform tr = target.getGridToCRS(PixelInCell.CELL_CENTER).inverse(); + if (crs != null && target.isDefined(GridGeometry.CRS)) { + final CoordinateOperation op = CRS.findOperation(crs, + target.getCoordinateReferenceSystem(), + target.getGeographicExtent().orElse(null)); + tr = MathTransforms.concatenate(op.getMathTransform(), tr); + } + crsToGrid = MathTransforms.bidimensional(tr); + } catch (IllegalArgumentException | FactoryException e) { - throw new TransformException(e); ++ throw new TransformException(null, e); + } + return crsToGrid.createTransformedShape(geometry); + } + + /** + * Compares this region of interest with the given object for equality. + * + * @param other the other object to compare with this ROI. + * @return whether the given object is equal to this ROI? + */ + @Override + public final boolean equals(final Object other) { + return equals(other, ComparisonMode.STRICT); + } + + /** + * Compares this region of interest with the given object for equality. + * + * @param other the other object to compare with this ROI. + * @param mode the comparison criterion. + * @return whether the given object is equal to this ROI? + */ + @Override + public boolean equals(final Object other, final ComparisonMode mode) { + if (other instanceof ComparisonMode) { + final RegionOfInterest that = (RegionOfInterest) other; + if (mode != ComparisonMode.STRICT || other.getClass() == getClass()) { + return geometry.equals(that.geometry) && Utilities.deepEquals(crs, that.crs, mode); + } + } + return false; + } + + /** + * Returns a hash code value for this region of interest. + * + * @return a hash code for this ROI. + */ + @Override + public int hashCode() { + return geometry.hashCode() + Objects.hashCode(crs); + } + } diff --cc core/sis-feature/src/main/java/org/apache/sis/coverage/SampleDimension.java index d5cb0ad,ce4e432..905fcbb --- a/core/sis-feature/src/main/java/org/apache/sis/coverage/SampleDimension.java +++ b/core/sis-feature/src/main/java/org/apache/sis/coverage/SampleDimension.java @@@ -69,8 -69,18 +69,15 @@@ import org.apache.sis.util.Debug * but organized in a different way. The use of the same name may seem a risk, but those two types are typically * not used at the same time. * + * <h2>Definition of missing data</h2> + * An important aspect of sample dimensions is the {@linkplain #getBackground() background value}. + * It defines how to initialize an empty image or canvas with respect to the sample definition. + * It can be thought as the value for "lack of data" (fill value, no-data, missing value) category + * when the missing value can not be categorized more precisely (cloud, instrument error, <i>etc</i>). + * * @author Martin Desruisseaux (IRD, Geomatys) + * @author Alexis Manin (Geomatys) * @version 1.1 - * - * @see org.opengis.metadata.content.SampleDimension - * * @since 1.0 * @module */ diff --cc core/sis-feature/src/main/java/org/apache/sis/filter/DefaultFilterFactory.java index 33da97c,b9b495a..feffd85 --- a/core/sis-feature/src/main/java/org/apache/sis/filter/DefaultFilterFactory.java +++ b/core/sis-feature/src/main/java/org/apache/sis/filter/DefaultFilterFactory.java @@@ -137,7 -130,7 +137,7 @@@ public abstract class DefaultFilterFact * * @todo The type of temporal object is not yet determined. */ - public static synchronized DefaultFilterFactory<AbstractFeature, Object, Object> forFeatures() { - public static FilterFactory<Feature, Object, Object> forFeatures() { ++ public static DefaultFilterFactory<AbstractFeature, Object, Object> forFeatures() { return Features.DEFAULT; } diff --cc core/sis-feature/src/main/java/org/apache/sis/filter/LogicalFilter.java index ac06b26,552e311..3c259e9 --- a/core/sis-feature/src/main/java/org/apache/sis/filter/LogicalFilter.java +++ b/core/sis-feature/src/main/java/org/apache/sis/filter/LogicalFilter.java @@@ -36,9 -37,9 +36,9 @@@ import org.apache.sis.internal.geoapi.f * * @author Johann Sorel (Geomatys) * @author Martin Desruisseaux (Geomatys) - * @version 1.1 + * @version 1.2 * - * @param <R> the type of resources (e.g. {@link org.opengis.feature.Feature}) used as inputs. + * @param <R> the type of resources (e.g. {@code Feature}) used as inputs. * * @since 1.1 * @module diff --cc core/sis-feature/src/test/java/org/apache/sis/filter/LogicalFilterTest.java index 8cf0dd4,a600504..0f8394f --- a/core/sis-feature/src/test/java/org/apache/sis/filter/LogicalFilterTest.java +++ b/core/sis-feature/src/test/java/org/apache/sis/filter/LogicalFilterTest.java @@@ -178,10 -182,13 +178,13 @@@ public final strictfp class LogicalFilt */ @Test public void testOptimization() { - final Filter<AbstractFeature> f1 = factory.isNull(factory.literal("text")); - final Filter<AbstractFeature> f2 = factory.isNull(factory.literal(null)); - final Filter<Feature> f1 = factory.isNull(factory.literal("text")); // False - final Filter<Feature> f2 = factory.isNull(factory.literal(null)); // True - final Filter<Feature> f3 = factory.isNull(factory.property("*")); // Indeterminate ++ final Filter<AbstractFeature> f1 = factory.isNull(factory.literal("text")); // False ++ final Filter<AbstractFeature> f2 = factory.isNull(factory.literal(null)); // True ++ final Filter<AbstractFeature> f3 = factory.isNull(factory.property("*")); // Indeterminate optimize(factory.and(f1, f2), Filter.exclude()); optimize(factory.or (f1, f2), Filter.include()); + optimize(factory.and(f3, factory.not(f3)), Filter.exclude()); + optimize(factory.or (f3, factory.not(f3)), Filter.include()); } /** diff --cc storage/sis-storage/src/main/java/org/apache/sis/internal/storage/TiledGridCoverage.java index 917c37b,b5ffb7b..efc1848 --- a/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/TiledGridCoverage.java +++ b/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/TiledGridCoverage.java @@@ -25,7 -25,8 +25,7 @@@ import java.awt.image.ColorModel import java.awt.image.SampleModel; import java.awt.image.MultiPixelPackedSampleModel; import java.awt.image.RenderedImage; - import java.awt.image.WritableRaster; + import java.awt.image.Raster; -import org.opengis.coverage.CannotEvaluateException; import org.opengis.geometry.MismatchedDimensionException; import org.apache.sis.coverage.grid.GridCoverage; import org.apache.sis.coverage.grid.GridExtent; diff --cc storage/sis-storage/src/main/java/org/apache/sis/internal/storage/TiledGridResource.java index 4f9a4d6,ff37952..d0dcbc4 --- a/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/TiledGridResource.java +++ b/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/TiledGridResource.java @@@ -23,9 -23,10 +23,9 @@@ import java.awt.image.ColorModel import java.awt.image.SampleModel; import java.awt.image.BandedSampleModel; import java.awt.image.ComponentSampleModel; + import java.awt.image.Raster; import java.awt.image.RenderedImage; - import java.awt.image.WritableRaster; import java.awt.image.RasterFormatException; -import org.opengis.coverage.CannotEvaluateException; import org.apache.sis.coverage.SampleDimension; import org.apache.sis.coverage.grid.GridCoverage; import org.apache.sis.coverage.grid.GridCoverage2D; @@@ -33,8 -34,6 +33,7 @@@ import org.apache.sis.coverage.grid.Gri import org.apache.sis.coverage.grid.GridExtent; import org.apache.sis.coverage.grid.GridGeometry; import org.apache.sis.coverage.grid.GridRoundingMode; +import org.apache.sis.coverage.CannotEvaluateException; - import org.apache.sis.storage.DataStore; import org.apache.sis.storage.DataStoreException; import org.apache.sis.storage.RasterLoadingStrategy; import org.apache.sis.storage.event.StoreListeners;