This is an automated email from the ASF dual-hosted git repository. desruisseaux pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/sis.git
commit 8ef62b01f52635d9d5a22e3263294e6565bd1a34 Merge: 95477cf094 8c45b25f06 Author: Martin Desruisseaux <[email protected]> AuthorDate: Thu Feb 5 16:22:47 2026 +0100 Merge branch 'geoapi-3.1' .../org.apache.sis.feature/main/module-info.java | 2 +- .../apache/sis/coverage/grid/DefaultEvaluator.java | 148 ++++++++++--------- .../coverage/grid/FractionalGridCoordinates.java | 157 +-------------------- .../sis/coverage/grid/ValuesAtPointIterator.java | 13 +- .../org/apache/sis/coverage/grid/package-info.java | 2 +- .../org/apache/sis/feature/AbstractFeature.java | 45 +----- .../org/apache/sis/feature/DefaultFeatureType.java | 4 +- .../main/org/apache/sis/feature/DenseFeature.java | 14 +- .../main/org/apache/sis/feature/SparseFeature.java | 14 +- .../sis/feature/internal/shared/FeatureView.java | 21 --- .../main/org/apache/sis/feature/package-info.java | 2 +- .../main/org/apache/sis/filter/Optimization.java | 31 +--- .../main/org/apache/sis/filter/package-info.java | 2 +- .../sis/coverage/grid/DefaultEvaluatorTest.java | 48 +++++++ .../grid/FractionalGridCoordinatesTest.java | 50 ------- .../main/module-info.java | 2 +- .../main/org/apache/sis/referencing/CRS.java | 29 +--- .../org/apache/sis/referencing/package-info.java | 2 +- .../org/apache/sis/storage/geotiff/Writer.java | 2 +- .../org.apache.sis.storage/main/module-info.java | 2 +- .../main/org/apache/sis/storage/FeatureQuery.java | 27 +--- .../main/org/apache/sis/storage/package-info.java | 2 +- .../src/org.apache.sis.util/main/module-info.java | 2 +- .../main/org/apache/sis/math/Fraction.java | 30 +--- .../main/org/apache/sis/math/NumberType.java | 11 +- .../main/org/apache/sis/math/package-info.java | 2 +- .../main/org/apache/sis/measure/UnitDimension.java | 5 +- .../main/org/apache/sis/util/Classes.java | 81 +---------- .../main/org/apache/sis/util/Numbers.java | 156 +------------------- .../org/apache/sis/util/collection/Containers.java | 41 +----- .../apache/sis/util/collection/package-info.java | 2 +- .../apache/sis/util/internal/shared/Numerics.java | 2 +- .../main/org/apache/sis/util/package-info.java | 2 +- .../test/org/apache/sis/util/ClassesTest.java | 35 +---- .../org/apache/sis/storage/isobmff/Reader.java | 6 +- .../apache/sis/storage/isobmff/gimi/ModelCRS.java | 28 ++-- .../sis/storage/gsf/panama/LibraryLoader.java | 3 +- .../main/org/apache/sis/storage/gdal/GDAL.java | 2 +- .../apache/sis/storage/panama/LibraryLoader.java | 3 +- .../apache/sis/storage/panama/NativeFunctions.java | 10 +- 40 files changed, 233 insertions(+), 807 deletions(-) diff --cc endorsed/src/org.apache.sis.feature/main/org/apache/sis/coverage/grid/DefaultEvaluator.java index 65f3acb06d,d5f815a7df..489d6a50fa --- a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/coverage/grid/DefaultEvaluator.java +++ b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/coverage/grid/DefaultEvaluator.java @@@ -370,77 -394,71 +392,71 @@@ abstract class DefaultEvaluator impleme int inputCoordinateOffset = 0; int firstCoordToTransform = 0; int numPointsToTransform = 0; - try { - /* - * Convert the "real world " coordinates to grid coordinates. - * The CRS of each point is verified. Consecutive points with - * the same CRS will be transformed in a single operation. - */ - for (final DirectPosition point : points) { - if (crs != (crs = point.getCoordinateReferenceSystem())) { - if (numPointsToTransform > 0) { // Because `toGrid` may be null. - assert toGrid.getTargetDimensions() == dimension; - toGrid.transform(coordinates, firstCoordToTransform, - coordinates, firstCoordToTransform, - numPointsToTransform); - } - firstCoordToTransform += numPointsToTransform * dimension; - inputCoordinateOffset = firstCoordToTransform; - numPointsToTransform = 0; - toGrid = getInputToGrid(crs); - srcDim = toGrid.getSourceDimensions(); - } - int offset = inputCoordinateOffset; - if ((inputCoordinateOffset += srcDim) > coordinates.length) { - int n = firstCoordToTransform / dimension; // Number of points already transformed. - n = points.size() - n + numPointsToTransform; // Number of points left to transform. - coordinates = Arrays.copyOf(coordinates, Math.multiplyExact(n, Math.max(srcDim, dimension)) + offset); - } - for (int i=0; i<srcDim; i++) { - coordinates[offset++] = point.getOrdinate(i); + /* + * Convert the "real world " coordinates to grid coordinates. + * The CRS of each point is verified. Consecutive points with + * the same CRS will be transformed in a single operation. + */ + for (final DirectPosition point : points) { + if (crs != (crs = point.getCoordinateReferenceSystem())) { + if (numPointsToTransform > 0) { // Because `toGrid` may be null. + assert toGrid.getTargetDimensions() == dimension; + toGrid.transform(coordinates, firstCoordToTransform, + coordinates, firstCoordToTransform, + numPointsToTransform); } - numPointsToTransform++; + firstCoordToTransform += numPointsToTransform * dimension; + inputCoordinateOffset = firstCoordToTransform; + numPointsToTransform = 0; + toGrid = getInputToGrid(crs); + srcDim = toGrid.getSourceDimensions(); } - /* - * Transforms the remaining sequence of points. - * Actually, in most cases, all points are transformed here. - */ - if (numPointsToTransform > 0) { // Because `toGrid` may be null. - assert toGrid.getTargetDimensions() == dimension; - toGrid.transform(coordinates, firstCoordToTransform, - coordinates, firstCoordToTransform, - numPointsToTransform); + int offset = inputCoordinateOffset; + if ((inputCoordinateOffset += srcDim) > coordinates.length) { + int n = firstCoordToTransform / dimension; // Number of points already transformed. + n = points.size() - n + numPointsToTransform; // Number of points left to transform. + coordinates = Arrays.copyOf(coordinates, Math.multiplyExact(n, Math.max(srcDim, dimension)) + offset); } - final int numPoints = firstCoordToTransform / dimension + numPointsToTransform; - postTransform(coordinates, 0, numPoints); - /* - * Create the iterator. The `ValuesAtPointIterator.create(…)` method will identify the slices in - * n-dimensional coverage, get the rendered images for the regions of interest and get the tiles. - */ - final IntFunction<PointOutsideCoverageException> ifOutside; - if (nullIfOutside) { - ifOutside = null; - } else { - final var listOfPoints = (points instanceof List<?>) ? (List<? extends DirectPosition>) points : null; - ifOutside = (index) -> { - DirectPosition point = null; - if (listOfPoints != null) try { - point = listOfPoints.get(index); - } catch (IndexOutOfBoundsException e) { - recoverableException("pointOutsideCoverage", e); - } - if (point != null) { - return pointOutsideCoverage(point); - } - return new PointOutsideCoverageException(Resources.format(Resources.Keys.PointOutsideCoverageDomain_1, "#" + index)); - }; + for (int i=0; i<srcDim; i++) { - coordinates[offset++] = point.getCoordinate(i); ++ coordinates[offset++] = point.getOrdinate(i); } - return StreamSupport.stream(ValuesAtPointIterator.create(coverage, coordinates, numPoints, ifOutside), parallel); - } catch (CannotEvaluateException ex) { - throw ex; - } catch (RuntimeException | FactoryException | TransformException ex) { - throw new CannotEvaluateException(ex.getMessage(), ex); + numPointsToTransform++; + } + /* + * Transforms the remaining sequence of points. + * Actually, in most cases, all points are transformed here. + */ + if (numPointsToTransform > 0) { // Because `toGrid` may be null. + assert toGrid.getTargetDimensions() == dimension; + toGrid.transform(coordinates, firstCoordToTransform, + coordinates, firstCoordToTransform, + numPointsToTransform); + } + final int numPoints = firstCoordToTransform / dimension + numPointsToTransform; + postTransform(coordinates, 0, numPoints); + /* + * Create the iterator. The `ValuesAtPointIterator.create(…)` method will identify the slices in + * n-dimensional coverage, get the rendered images for the regions of interest and get the tiles. + */ + final IntFunction<PointOutsideCoverageException> ifOutside; + if (nullIfOutside) { + ifOutside = null; + } else { + final var listOfPoints = (points instanceof List<?>) ? (List<? extends DirectPosition>) points : null; + ifOutside = (index) -> { + DirectPosition point = null; + if (listOfPoints != null) try { + point = listOfPoints.get(index); + } catch (IndexOutOfBoundsException e) { + recoverableException("pointOutsideCoverage", e); + } + if (point != null) { + return pointOutsideCoverage(point); + } + return new PointOutsideCoverageException(Resources.format(Resources.Keys.PointOutsideCoverageDomain_1, "#" + index)); + }; } + return ValuesAtPointIterator.create(coverage, coordinates, numPoints, ifOutside); } /** diff --cc endorsed/src/org.apache.sis.feature/main/org/apache/sis/coverage/grid/FractionalGridCoordinates.java index c0c1f711a0,17853d7e66..30814bf536 --- a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/coverage/grid/FractionalGridCoordinates.java +++ b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/coverage/grid/FractionalGridCoordinates.java @@@ -24,13 -24,10 +24,7 @@@ import org.opengis.referencing.operatio import org.apache.sis.geometry.GeneralDirectPosition; import org.apache.sis.feature.internal.Resources; import org.apache.sis.util.StringBuilders; - import org.apache.sis.util.internal.shared.Strings; - import org.apache.sis.util.resources.Errors; - - // Specific to the main branch: - import org.opengis.geometry.MismatchedDimensionException; - import org.apache.sis.coverage.PointOutsideCoverageException; -// Specific to the geoapi-3.1 and geoapi-4.0 branches: -import org.opengis.coverage.grid.GridCoordinates; - /** * Grid coordinates which may have fraction digits after the integer part. diff --cc endorsed/src/org.apache.sis.feature/main/org/apache/sis/feature/AbstractFeature.java index 24cb5bc6a9,be24226f52..285723dd88 --- a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/feature/AbstractFeature.java +++ b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/feature/AbstractFeature.java @@@ -340,11 -347,8 +338,7 @@@ public abstract class AbstractFeature i * * @see AbstractAttribute#getValue() */ - public Object getPropertyValue(final String name) throws IllegalArgumentException { - final Object value = getValueOrFallback(name, MISSING); - if (value != MISSING) return value; - throw new IllegalArgumentException(propertyNotFound(type, getName(), name)); - } - @Override - public abstract Object getPropertyValue(String name) throws PropertyNotFoundException; ++ public abstract Object getPropertyValue(String name) throws IllegalArgumentException; /** * Sets the value for the property of the given name. @@@ -363,35 -367,9 +357,8 @@@ * * @see AbstractAttribute#setValue(Object) */ - @Override public abstract void setPropertyValue(final String name, final Object value) throws IllegalArgumentException; - /** - * Returns the value for the property of the given name if that property exists, or a fallback value otherwise. - * This method is equivalent to the following code, but potentially more efficient: - * - * {@snippet lang="java" : - * return type.hasProperty(name) ? getPropertyValue(name) : missingPropertyFallback; - * } - * - * Note that if a property of the given name exists but has no value, then this method returns the - * {@linkplain DefaultAttributeType#getDefaultValue() default value} (which may be {@code null}). - * <i>Property without value</i> is not equivalent to <i>non-existent property</i>. - * - * @param name the property name. - * @param missingPropertyFallback the (potentially {@code null}) value to return - * if no attribute or association of the given name exists. - * @return value or default value of the specified property, or {@code missingPropertyFallback} - * if no attribute or association of that name exists. This value may be {@code null}. - * - * @since 1.1 - * - * @deprecated Experience suggests that this method encourage bugs in user's code that stay unnoticed. - */ - @Deprecated(since = "1.5", forRemoval = true) - public Object getValueOrFallback(final String name, Object missingPropertyFallback) { - return type.hasProperty(name) ? getPropertyValue(name) : missingPropertyFallback; - } - /** * Executes the parameterless operation of the given name and returns the value of its result. * This is a convenience method for sub-classes where some properties may be operations that @@@ -780,12 -714,12 +747,12 @@@ * Returns the exception message for a property not found. The message will differ depending * on whether the property is not found because ambiguous or because it does not exist. * - * @param feature the name of the feature where a property where searched ({@link String} or {@link GenericName}). + * @param feature the the feature where a property where searched. * @param property the name of the property which has not been found. */ - static String propertyNotFound(final FeatureType type, final Object feature, final String property) { + static String propertyNotFound(final FeatureType feature, final String property) { GenericName ambiguous = null; - for (final AbstractIdentifiedType p : type.getProperties(true)) { - for (final IdentifiedType p : feature.getProperties(true)) { ++ for (final AbstractIdentifiedType p : feature.getProperties(true)) { final GenericName next = p.getName(); GenericName name = next; do { diff --cc endorsed/src/org.apache.sis.feature/main/org/apache/sis/feature/DefaultFeatureType.java index 8f5ebf7270,d764cbcb5b..be3be32256 --- a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/feature/DefaultFeatureType.java +++ b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/feature/DefaultFeatureType.java @@@ -879,7 -879,7 +879,7 @@@ public class DefaultFeatureType extend if (pt != null) { return pt; } - throw new IllegalArgumentException(AbstractFeature.propertyNotFound(this, getName(), name)); - throw new PropertyNotFoundException(AbstractFeature.propertyNotFound(this, name)); ++ throw new IllegalArgumentException(AbstractFeature.propertyNotFound(this, name)); } /** diff --cc endorsed/src/org.apache.sis.feature/main/org/apache/sis/feature/DenseFeature.java index 6002074a80,19e9c9dbae..bc516c93da --- a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/feature/DenseFeature.java +++ b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/feature/DenseFeature.java @@@ -88,7 -94,7 +88,7 @@@ final class DenseFeature extends Abstra return index; } ArgumentChecks.ensureNonNull("name", name); - throw new IllegalArgumentException(propertyNotFound(type, getName(), name)); - throw new PropertyNotFoundException(propertyNotFound(type, name)); ++ throw new IllegalArgumentException(propertyNotFound(type, name)); } /** @@@ -181,7 -183,7 +177,7 @@@ ArgumentChecks.ensureNonNull("name", name); final Integer index = indices.get(name); if (index == null) { - return missingPropertyFallback; - throw new PropertyNotFoundException(propertyNotFound(type, name)); ++ throw new IllegalArgumentException(propertyNotFound(type, name)); } if (index < 0) { return getOperationValue(name); diff --cc endorsed/src/org.apache.sis.feature/main/org/apache/sis/feature/SparseFeature.java index 706e4b656d,14b8530faa..080446f7d6 --- a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/feature/SparseFeature.java +++ b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/feature/SparseFeature.java @@@ -121,7 -128,7 +121,7 @@@ final class SparseFeature extends Abstr if (index != null) { return index; } - throw new IllegalArgumentException(propertyNotFound(type, getName(), name)); - throw new PropertyNotFoundException(propertyNotFound(type, name)); ++ throw new IllegalArgumentException(propertyNotFound(type, name)); } /** @@@ -227,7 -230,7 +223,7 @@@ ArgumentChecks.ensureNonNull("name", name); final Integer index = indices.get(name); if (index == null) { - return missingPropertyFallback; - throw new PropertyNotFoundException(propertyNotFound(type, name)); ++ throw new IllegalArgumentException(propertyNotFound(type, name)); } if (index < 0) { return getOperationValue(name); diff --cc endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/CRS.java index 0ab5c18752,19a768dad2..c3e7f38698 --- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/CRS.java +++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/CRS.java @@@ -101,12 -101,11 +101,11 @@@ import org.apache.sis.coordinate.Defaul // Specific to the main and geoapi-3.1 branches: import org.opengis.referencing.crs.GeneralDerivedCRS; -// Specific to the geoapi-3.1 and geoapi-4.0 branches: -import org.opengis.referencing.ObjectDomain; -import org.opengis.referencing.crs.DerivedCRS; -import org.opengis.referencing.datum.DynamicReferenceFrame; -import org.opengis.coordinate.CoordinateMetadata; +// Specific to the main branch: - import org.apache.sis.referencing.DefaultObjectDomain; +import org.apache.sis.referencing.crs.AbstractCRS; +import org.apache.sis.referencing.datum.DefaultGeodeticDatum; +import org.apache.sis.referencing.datum.DefaultVerticalDatum; +import static org.apache.sis.pending.geoapi.referencing.MissingMethods.getDatumEnsemble; /**
